Shell Scripting - Need some help
HELP ${var%/*}
Hello I have a list of a whole bunch of cpp 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 I think I should use something like ${varname%/*}, but im not sure how to use it. I read file names off the command line, using $1, $2, I have the path saved in a variable called x x=$1 in my loop i use find, and it prints the first list of directories THanks for the hlep :confused: |
You can try to use dirname:
Code:
echo "/pub/program/file1.c" | xargs dirname |
All times are GMT -5. The time now is 01:15 PM. |