我正在寻找有关如何使用 getopts
显示不带基名的目录名的信息。
这应该首先为我计算机中的所有 sh 文件提供基本名称、制表符,然后是所有
目录。
例如,如果我这样做:myBashfile.sh -e *sh
我需要看到输出:
test1.sh /home/directory5/directory6
test60.sh /home/directory50/directory6
anothertest.sh /home/directory5/directory6
目前我有这个:
while getopts b opt
do
case $opt in
b) find / -name $OPTARG -printf "%f\n"-print 2>/dev/null ;;
esac
done
只显示这个:
test1.sh
test60.sh
anothertest.sh
最佳答案
-printf "%-20f %h"
怎么样?
关于linux - Linux 上的 printf 路径名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10960685/