2014년 7월 13일 일요일

[linux shell] full path/file name/file extension

FULLPATH=/usr/share/test/test.sh

# remove all the prefix until "/" character
FILENAME=${FULLPATH##*/}

# remove all the prefix until "." character
FILEEXTENSION=${FILENAME##*.}

#remove a suffix, in our cas, the filename, this will return the name of the directory
BASEDIRECTORY=${FULLPATH%$FILENAME}

댓글 없음 :

댓글 쓰기