hi all,
suppose a string:
abc/def/ghi/jkl/mn.txt
and i want to get the file name without the path.
however, different files have different paths, therefore the number of delimiter is uncertain.
thanks so much!
hi all,
suppose a string:
abc/def/ghi/jkl/mn.txt
and i want to get the file name without the path.
however, different files have different paths, therefore the number of delimiter is uncertain.
thanks so much!
$ echo "abc/def/gh/joe.txt" | awk -F"/" '{print $NF}'
joe.txt
Try using basename <full_path_to_file>
$ basename /sndc002/app/appsndc/sndcappl/admin/sndc01.txt
sndc01.txt
If you are doing this within a loop, you may want to consider using the built-in feature of bash/ksh parameter expansion. This will save you 1 exec for every loop
v="abc/def/ghi/jkl/mn.txt"
echo ${v##*/}