Regex to match lines that access a certain port and particular packets
Solution 1:
With positive lookahead, you can match something that should not be part of the result:
grep -Po '(\d+\.){3}\d+(?=\s22\s)' hw0206.txt
In this case, I would prefer awk
which gives a more readable solution:
awk '$5 == 22 {print $4}' hw0206.txt