New to Linux and the only way I can get this to work is by using the awk command unfortunately the main directions specify to not use awk.
this is what I got
#!/bin/sh
#comment Write a single RegEx to match the lines that access port 22 and only those packets
grep '\s22\s' hw0206.txt | awk {'print $4'}
#comment grep returns the whole line with matched string
#comment \s22\s regular expression to match any string containing 22 preceded or succeeded by white space
instructions
Write a single RegEx to match the lines that access port 22 and only those packets, and then return the IP address
Input file (hw0206.txt) Expected output of script
date time protocol ip-address port packet-size
2022-02-21 19:22:19 TCP 22.101.2.24 22 24
2018-22-22 02:25:12 UDP 10.221.7.22 2135 222
2200-05-22 22:26:22 UDP 22.122.6.62 2160 22
2012-22-20 15:43:22 TCP 10.121.7.222 22 122
1228-02-10 02:22:02 UDP 22.102.2.62 2089 22
date time protocol ip-address port packet-size
2022-02-21 19:22:19 TCP 22.101.2.24 22 24
2018-22-22 02:25:12 UDP 10.221.7.22 2135 222
2200-05-22 22:26:22 UDP 22.122.6.62 2160 22
2012-22-20 15:43:22 TCP 10.121.7.222 23 122
1228-02-10 02:22:02 TCP 22.102.2.62 22 22
2100-05-25 21:26:22 UDP 22.112.63.62 2122 22