Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这段 bash 代码在存在许多文件夹时没有显示文件夹名称。
#!/bin/bash for file in .; do if [ -d $file ]; then echo $file fi done
输出只是. 你能解释一下为什么吗?
.
它读取.为大小为 1 的数组并为您打印。改用这样的东西:
for file in `ls`; do if [ -d $file ]; then echo $file fi done