优雅的获取文件名及文件路径
#第一种方法
for file in ./*; do
if [ -f "$file" ] ; # the option -f could be replace by -e or -d, if you want all things in the directory or directory name
then
filename=${file##*/}
echo "$filename"
fi
done
第二种方法
for file in ./*; do
if [ -f "$file" ] ; # the option -f could be replace by -e or -d, if you want all things in the directory or directory name
then
filename=`basename "$file"`
echo "$filename"
fi
done