我正在寻找" for loop"以在每个direcorty中运行多个脚本并将输出保存在同一目录中
#!/bin/bash
for dir in /home/Desktop/4Testing/batch_2019-05-16/* # inside batch_2019-05-16 there are 400 folders"
do
dir=${dir%*/} # remove the trailing "/"
echo "$1" *.pcap > 12.txt # print everything after the final "/"
tshark -r *.pcap -T fields -e frame.time -e _ws.col.Source -e _ws.col.Destination -e frame.len -e _ws.col.src.prt -e _ws.col.dst.prt -E separator=, > home.csv
cat home.txt 12.txt > Final.csv
done
如果您的目录名称具有空格/怪异字符或文件,则可能会遇到麻烦!将您的处理存储在函数/脚本中,该函数/脚本将目录名称作为参数并使用find
,例如:
find /home/Desktop/4Testing/batch_2019-05-16 -maxdepth 1 -type d -exec <script_name> {} ;