简体   繁体   English

Bash:如何遍历目录文件?

[英]Bash: how can I loop through a directory's files?

在Bash中,如果我试图遍历目录中的所有文件并对它们执行命令,则_ in _循环中的_会是什么样?

for file in *
do
    perform_command_on "$file"
done

一个简单for

for f in dir/*; do echo "Processing $f file.."; done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用bash遍历命令以获取目录中文件数? - How to loop through the command for number of files in directory using bash? 如何循环浏览目录中的文件,然后将它们读入bash中的字符串变量 - How to loop through files in a directory and then read them into a string variable in bash 如何遍历bash给定目录中指定类型的所有文件? - How to loop through all files of a specified type in a given directory in bash? 重击/自动化。 如何循环遍历目录,更改文件名并将文件保留在目录中? - Bash/ Automator. How to Loop through directory, change name of files and keep files in directory? 我如何编写一个 bash 脚本来遍历文件夹中的每个目录并将所有 .txt 文件附加到一个文件中? - How do i write a bash script to loop through each directory in a folder and append all .txt files into a single file? bash ~ 如何在目录中搜索文件 - bash ~ How to search through files in a directory 如何在 Bash 中使用 for 循环迭代目录中的文件 - How to iterate files in directory with for loop in Bash 如何从bash中的目录中选择随机文件? - How can I select random files from a directory in bash? 如何在目录中列出文件x到y(重击) - How can I list files x to y in a directory (Bash) bash - 遍历子目录、cat 文件并用目录名重命名 - bash - loop through subdirectories, cat files and rename with directory name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM