I have some analysis code on a computing cluster. The output of the code is a table of floating point numbers. The final output is printed to standard out, with a bunch of other messages preceding it and following it. It looks something like this:
Welcome to Computer X
Setting up parallel environment...
Setup complete. Running tasks....
0.059 9.342114 10.324921 0.3 0
0.123 123.4231102 231.49 45.7 84
Job completed on July 4, 1776
Thank you and have a nice day
I need to extract the numbers only. Unfortunately, I don’t know a priori how many digits will comprise each number (is it going to be 0.342123 or 1 or 1.05), and how many of the text lines will precede or follow the number.
I have used grep before, but I don’t know much of anything about regular expressions. I looked up examples for, say, how to match phone numbers (###-###-####) etc., but I couldn’t think of anything where you don’t know how many digits to skip. The only thing I do know is that there will be, say, 5 columns of data to extract.
Use
grep -howith regex patternor if you sure 5 numbers are always in row, then