1

I have following type of data in my .log file:

Cell[BoxData["0.8693473380926441`"]
Cell[BoxData["100.40266203596555`"]
Cell[BoxData["23.338724857049048`"]
Cell[BoxData["0.25720321805387686`"]
Cell[BoxData["66.85236878385265`"]

I want to grep only the numeric numbers, like:

0.8693473380926441
100.40266203596555
23.338724857049048
0.25720321805387686
66.85236878385265

I have tried, grep -Po '\[.*?]', but it only eliminates one brackets. Any help will be appreciated.

3

awk is better for this:

awk -F '["`]' '{print $2}' file

That sets the field separator as either " or a tilde and then prints the second column/field.

Output:

0.8693473380926441
100.40266203596555
23.338724857049048
0.25720321805387686
66.85236878385265
  • Its perfect, Thank you very much – Amanullah Malik Jun 24 '19 at 15:53
  • @AmanullahMalik. You are welcome. – Nasir Riley Jun 24 '19 at 15:56
0

I tried with below mentioned command and worked fine

 sed 's/.*\["//g' filename| sed 's/`"\]//g'

output

0.8693473380926441
100.40266203596555
23.338724857049048
0.25720321805387686
66.85236878385265
  • If you're going to use sed for this then you don't need to call it twice. You can use -e for multiple statements. – Nasir Riley Jul 2 '19 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.