繁体   English   中英

针对目录和子目录中的所有txt文件运行脚本-BASH

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM