I have a file which has many lines of the format:
bc("STG1/Phone") = {type=bana_pub; cbb=12.354; abb=0.0}`
I'm looking to extract cbb=12.354;
. Currently, I'm doing the following:
cat input_file.txt | grep cbb | awk -F " " '{ print $4 }'`
The problem is that my approach is location specific i.e. assumes it's always 4th field. How do I extract text of the form cbb=
knowing after the =
it could be any length and the semi-colon ;
is optional. The only guarantee I have is that the term cbb=12.354;
will be surrounded by whitespace if that helps. The file in future may be of the format:
bc("STG1/Phone") = {type=bana_pub; cbb=12.354; abb=0.0}
bc("STG1/Phone") = {type=bana_pub; abb=0.0; cbb=12.354}
My gut tells me regex is probably the way to go, but I generally try and avoid it if I can as I prefer simple matching tools (which I understand better).
Thanks in anticipation for your help.