Can we add the values generated by multiple commands? For example, I am analysing this pcap file using tcpdump, and by doing this - capinfos -s *.pcap, I am getting all the pcap files' size, line by line. Can anyone tell me how to add those in the terminal itself? I'm not expecting appending the values in csv or txt file and add those.
You could use awk
both for filtering the size lines and for adding the sizes ($3
, as $1
is File
and $2
is size:
):
capinfos -s *.pcap|awk '/File size:/ {sum += $3}
END {print sum}'