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 妈妈生日祝福语简短励志