sed/awk, instead of Perl

Steve Bertrand steve at
Thu Aug 21 12:50:49 UTC 2008

Steve Bertrand wrote:

> To put it plainly, can anyone, if it's possible, provide a single line 
> sed/awk pipeline that can:

To answer my own post, I found in some past notes something I drummed up 
quite a while ago that I can most certainly modify to suit my needs:

# Cat the tcpdump output file
# confirm that the source IP is NOT the mail server, and print the 
source IP/port
# separate the IP/port entries
# eliminate only the port and print IP
# clean out the spaces in the IP

cat tcpdump.txt | awk '{if ($3 != "") print $3}' | \
awk '{FS = "."} {print $1,".",$2,".",$3,"."$4}' | sed s/" "//g


More information about the freebsd-questions mailing list