If you have a text file where the word 'src:' appears in every line just different fields. What shell command is best to search for 'src:' and then print the next field. Same for 'dst:'
Text file would contain the following string on every line just at different fields locations.
'src: x.x.x.x; dst: x.x.x.x;'
In the past I was able to just use awk w/ print because the field was constant.
BEGIN {
FS=";"
# IP is a kind of lame regex, but.....
IP="[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*"
pat = (( pat == "") ? "src: " : pat " ") IP
}
$0 ~ pat {
for(i=1; i <=NF; i++)
if ($i ~ pat)
print $(i+1)
}
How would I get service: bla also. I tried several 100 things since my last post but I am evidently and ID10T and cant seem to get it to pull service: bla in cordinance w/ src and dest.