本文介绍了while 循环的输入来自 `command` 的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#I used to have this, but I don't want to write to the disk
#
pcap="somefile.pcap"
tcpdump -n -r $pcap > all.txt
while read line; do
ARRAY[$c]="$line"
c=$((c+1))
done < all.txt
以下方法无效.
# I would prefer something like...
#
pcap="somefile.pcap"
while read line; do
ARRAY[$c]="$line"
c=$((c+1))
done < $( tcpdump -n -r "$pcap" )
Google 上的结果太少(不明白我想找到什么 :( ).我想保持它与 Bourne 兼容 (/bin/sh),但它没有em> 成为.
Too few results on Google (doesn't understand what I want to find :( ). I'd like to keep it Bourne-compatible (/bin/sh), but it doesn't have to be.
推荐答案
for line in $(tcpdump -n -r $pcap)
do
command
done
这并没有完全满足我的需求.但它很接近.与Shell兼容.我正在从 tcpdump 输出创建 HTML 表.for
循环创建了一个新的 <tr>每个单词的行.它应该为每个行( 结尾)创建一个新行.粘贴 bin script01.sh.
This isn't exactly doing what I need. But it is close. And Shell compatible. I'm creating HTML tables from the tcpdump output. The for
loop makes a new <tr> row for each word. It should make a new row for each line ( ending).Paste bin script01.sh.
这篇关于while 循环的输入来自 `command` 的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!