Hi I'm currently writing shell script and need to get the value from a column when the next column matches a value. An example of the output to be search is below.
con1{649}: AES_CBC_256/HMAC_SHA2_256_128/MODP_2048, 306081 bytes_i, 444452 bytes_o, rekeying in 6 minutes
So in the above output I'm look to extract the "306081" but as the column can move I want to grab the column befores value of "bytes_i"
I've tried the following but it fails to return as value ipsec statusall | grep con1{ | awk -v b="bytes_i" '{for (i=1;i\<=NF;i++) { if ($i == b) { print i } }}
I was thinking if I could get the colume number of bytes_i I could subtrack 1 and then use awk to grab that column value but I'm open to suguestions.