![](/img/trans.png)
[英]How to loop through all files of a specified type in a given directory in bash?
[英]How do I loop through files in a directory given from the command line?
我正在尝试从命令行构建一个脚本。 但是每次我运行时,我的 echo 命令只打印目录名称而不是目录中的文件。
for EachFile in $1:
do
#Do stuff
echo "Filename is $EachFile"
done
冒号在路径中没有特殊含义。 使用全局:
for file in "$1"/* ; do
printf '%s\n' "$file"
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.