teddy@toshiba~$ a="76"
teddy@toshiba~$ echo $((a+3))
79
teddy@toshiba~$ echo $((a-12))
64
teddy@toshiba~$
取文件名以及文件路径的脚本:
#!/bin/sh
tmp=$1
filename=`echo $1 | awk -F/ '{print $(NF)}'`
echo "filename":$filename
filenamelength=`echo | awk '{print length("'${filename}'")}' `
totallength=`echo | awk '{print length("'${tmp}'")}' `
length=`echo $((totallength-filenamelength))`
filepath=`echo $tmp | cut -c -$length`
echo "filepath":$filepath
调用方式:
eamon@dxeamon:~/tmp$ sh a.sh 1/2/3/4/5/6
filename:6
filepath:1/2/3/4/5/
teddy@toshiba~$ echo $((a+3))
79
teddy@toshiba~$ echo $((a-12))
64
teddy@toshiba~$
取文件名以及文件路径的脚本:
#!/bin/sh
tmp=$1
filename=`echo $1 | awk -F/ '{print $(NF)}'`
echo "filename":$filename
filenamelength=`echo | awk '{print length("'${filename}'")}' `
totallength=`echo | awk '{print length("'${tmp}'")}' `
length=`echo $((totallength-filenamelength))`
filepath=`echo $tmp | cut -c -$length`
echo "filepath":$filepath
调用方式:
eamon@dxeamon:~/tmp$ sh a.sh 1/2/3/4/5/6
filename:6
filepath:1/2/3/4/5/