Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I extract the values from this data using bash and awk?

Tags:

grep

bash

awk

I grepped these, how do I extract the values?

...
cavity_2mgl_wt_strip57001.out: Total cavity volume (A3)               : (  1.240E+01) 
cavity_2mgl_wt_strip58001.out: Total cavity volume (A3)               : (  2.408E+00) 
cavity_2mgl_wt_strip60001.out: Total cavity volume (A3)               : (  4.935E+00) 
cavity_2mgl_wt_strip61001.out: Total cavity volume (A3)               : (  1.319E+00) 
cavity_2mgl_wt_strip63001.out: Total cavity volume (A3)               : (  1.532E-01) 
cavity_2mgl_wt_strip64001.out: Total cavity volume (A3)               : (  1.137E+01) 
...

and I need the index # in the filename in bold:

cavity_2mgl_wt_strip76001.out: Total cavity volume (A3)               : (  1.276E+01)

and I need the number in the parenthesis:

cavity_2mgl_wt_strip76001.out: Total cavity volume (A3)               : (  1.276E+01)
like image 258
ben Rod Avatar asked Mar 22 '26 03:03

ben Rod


1 Answers

sed 's/.*strip\(.*\).out.*(\([^:].*\))/\1 \2/' file
like image 70
ghostdog74 Avatar answered Mar 24 '26 23:03

ghostdog74