Bash 不使用`ls`列出文件
示例
使用Bashshell的文件名扩展和大括号扩展功能来获取文件名:
# display the files and directories that are in the current directory
printf "%s\n" *
# display only the directories in the current directory
printf "%s\n" */
# display only (some) image files
printf "%s\n" *.{gif,jpg,png}要将文件列表捕获到变量中进行处理,通常最好使用bash数组:
files=( * )
# iterate over them
for file in "${files[@]}"; do
echo "$file"
done
热门推荐
10 感谢韩语老师祝福语简短
11 升职文案高级祝福语简短
12 花童结婚祝福语大全简短
13 向国庆送祝福语简短
14 什么寄语简短祝福语女生
15 客户回礼祝福语大全简短
16 女孩生日祝福语简短创意
17 家长回复节日祝福语简短
18 给外婆敬酒祝福语简短