niedziela, 26 czerwca 2011

Bash and file name extraction

To extract file name from full path one can use the following syntax

file=/home/user/test
echo ${file##*/}

For path use

echo "${file%/*}"


And for extension

echo "${file##*.}"

Brak komentarzy:

Prześlij komentarz