shell for循环输出目录下的文件名

test.sh文件:
#!/bin/bash
for file in `ls`;do
        echo $file
done
输出
bogon:test macname$ chmod +x test.sh
bogon:test macname$ ./test.sh 
case
html
report
run.sh
test.sh

参考:

https://www.runoob.com/linux/linux-shell-variable.html

猜你喜欢

转载自www.cnblogs.com/sea-stream/p/11387675.html