文件名(basename)
filepath=/home/abc/ahaha.txt
filename=`basename $filepath`
echo filename #Result: ahaha.txt
路径名(dirname)
filepath=/home/abc/ahaha.txt
dirname=`dirname $filepath`
echo dirname #Result: /home/abc
filepath=/home/abc/ahaha.txt
filename=`basename $filepath`
echo filename #Result: ahaha.txt
filepath=/home/abc/ahaha.txt
dirname=`dirname $filepath`
echo dirname #Result: /home/abc
本文标题:Linux中获得文件名和路径名的方法
本文链接:https://www.haomeiwen.com/subject/fenzphtx.html
网友评论