input of while loop to come from output of `command`

后端 未结 4 1791
心在旅途
心在旅途 2021-02-04 02:16
#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=$(         


        
4条回答
  •  無奈伤痛
    2021-02-04 03:11

    This works in bash:

    while read line; do  
      ARRAY[$c]="$line"
      c=$((c+1))  
    done < <(tcpdump -n -r "$pcap")
    

提交回复
热议问题