首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >对多个文件运行命令并命名新文件

对多个文件运行命令并命名新文件
EN

Stack Overflow用户
提问于 2019-10-23 22:49:16
回答 1查看 36关注 0票数 0

这是一个bash脚本,我有5个PCAP文件,我想对它们运行这些命令,然后根据每个PCAP文件命名新文件flow1 flow2 flow3 flow4 flow5我无法让它正确命名这些文件

对于其中的一个文件,新文件显示为1 long string flow1 flow2 flow3 flow4 flow5

代码语言:javascript
复制
flow=(flow1 flow2 flow3 flow4 flow5)
dns=(dns1 dns2 dns3 dns4 dns5 dns6)
ntp=(ntp1 ntp2 ntp3 ntp4 ntp5 ntp6)

#creates a new directory based on the PCAP folder name 
for file in *.pcap
do
argus -r *.pcap -w packet.argus &&
#Run argus to get the flow volumn (totalbytes) and the flow duration (seconds)
#ra -r packet.argus -s bytes dur > flow_vol_dur.csv
ra -r packet.argus -s bytes dur -u > "${flow[*]}.csv"

ra -r packet.argus -n -s bytes dur rate runtime pkts load loss > features.csv &&                                                                       
#Run argus to get the source and destination ports, merge both columns together and count how many occurrences
#racluster -r packet.argus -n -s sport dport > ports.csv &&
ra -r packet.argus -n -s stime ltime sport dport - dst port 53 > "${dns[*]}.csv" 
ra -r packet.argus -n -s stime ltime sport dport - dst port 123 > "${ntp[*]}.csv" &&

rm packet.argus 

done
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-23 23:03:28

在不确切了解argusra命令的作用的情况下,我怀疑这更接近您的需求:

代码语言:javascript
复制
#!/bin/bash

count=0
for file in *.pcap; do
  ((count++))
  argus -r ${file} -w packet.argus
  ra -r packet.argus -s bytes dur -u > flow${count}.csv
  ra -r packet.argus -n -s bytes dur rate runtime pkts load loss > features.csv
  ra -r packet.argus -n -s stime ltime sport dport - dst port 53 > dns${count}.csv 
  ra -r packet.argus -n -s stime ltime sport dport - dst port 123 > ntp${count}.csv
  rm packet.argus 
done
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58525563

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档