[英]Bash Script to load all files in a directory/sub-directories into a Array
[英]Run script against all txt files in directory and sub directories - BASH
我试图做的是类似的东西(这是伪代码):
for txt in $(some fancy command ./*.txt); do
some command here $txt
您可以使用find
:
find /path -type f -name "*.txt" | while read txt; do
echo "$txt"; # Do something else
done
尝试
find . | grep ".txt" | xargs -I script.sh {}
find返回目录中的所有文件。 grep仅选择.txt文件,xargs将文件作为参数发送到script.sh
使用-exec
选项find
:
find /usr/share/wordlists/*/* -type f -name '*.txt' -exec yourScript {} \;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.