HELP ${var%/*}

This is a discussion on HELP ${var%/*} within the Linux Programming forums, part of the Platform Specific Boards category; Hello I have a list of a whole bunch of c files, and their directories for ex. C/program/test.cpp C/program/test1.h C/personal/math.h ...

  1. #1
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198

    HELP ${var%/*}

    Hello

    I have a list of a whole bunch of c files, and their directories
    for ex.

    C/program/test.cpp
    C/program/test1.h
    C/personal/math.h
    C/personal/iterate.cpp

    Now I would like to use ${var%/*} to remove the names of the files and the last /, but i dont know how. I need to do this, so I can use sort and uniq, which would result in

    C/program
    C/personal

    as being the directories that contain cpp files

    Thanks

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    the basename program grabs the filename off of a path. You might try useing that to get the name of the file, and then use some kind of string comparison program to get the value of the string minus the substring (the filename).

    starX
    www.axisoftime.com

  3. #3
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198
    Thanks

    But how would i I implenent it. Can you show me some code?


    Thanks again

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21