我抓了这些,如何提取值?
... 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) ...
我需要以粗体显示文件名中的索引#:
cavity_2mgl_wt_strip76001.out: Total cavity volume (A3) : ( 1.276E+01)
我需要括号中的数字:
cavity_2mgl_wt_strip76001.out: Total cavity volume (A3) : ( 1.276E+01)
$ ..<commands>.. | awk -F"[:)(]" '{gsub(".*strip|.out","",$1);print $1,$(NF-1)}'
57001 1.240E+01
58001 2.408E+00
60001 4.935E+00
61001 1.319E+00
63001 1.532E-01
64001 1.137E+01
Run Code Online (Sandbox Code Playgroud)
或者如果您的grepped值已经存在于文件中
$ awk -F"[:)(]" '{gsub(".*strip|.out","",$1);print $1,$(NF-1)}' file
Run Code Online (Sandbox Code Playgroud)