What is the conditional test in bash to determine if a variabl $f is a directory?
本问题已经有最佳答案,请猛点这里访问。
所以我正在扫描一个目录,想测试目录中的每个元素是否是一个目录:
1 2 3 4 5 6 7 8 9 | FILES=$PWD/* for f in $FILES do if [ $f is a directory ]; then #Correct conditional needed here echo"Dir: $f" fi done |
如果$f是目录,我应该使用什么方法/函数来测试?
用
1 | if [ -d"$f" ]; then |