我正在寻找“ for循环”以在每个目录中运行多个脚本并将输出保存在同一目录中
#!/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
答案 0 :(得分:0)
如果目录名称包含空格/怪异字符或文件,您可能会遇到麻烦!最好将处理存储在以目录名称为参数并使用find
的函数/脚本中,例如:
find /home/Desktop/4Testing/batch_2019-05-16 -maxdepth 1 -type d -exec <script_name> {} \;