Saturday, March 27, 2010

UNIX Shell(bash) 에서 filepath 를 directory명과 파일명으로 나누기

filepath=$1

dir=`dirname "$filepath"`
filename=`basename "$filepath"`
filenameonly=${filename%\.*}
ext=${filename##*.}

echo $dir
echo $filename
echo $filenameonly
echo $ext

No comments:

Post a Comment