获取文件名及目录

#!/usr/bin

x='/abc/def/ghi/qq.txt'

y=`echo ${x##*/}`

echo $y

lengtha=`expr length $x`

lengthb=`expr length $y`

length=` expr $lengtha - $lengthb`

path=`expr substr "$x" 1 $length`

echo $path

 

 

 

------------------------------------------------------------------------------

http://topic.csdn.net/u/20090714/18/3b1be11d-4303-4f45-a01b-3119858728dc.html

 

 

你可能感兴趣的:(获取文件名及目录)