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 红包祝福语简短10字
18 周六早晨祝福语简短