本文介绍了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
以下内容无法正常工作.
The following fails to work.
# 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),但它没有具有
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>.每个字排.它应为每条行(\ n结尾)创建一个新行.粘贴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 (\n ending).Paste bin script01.sh.
这篇关于while循环的输入来自`command`的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!