Reputation: 3
I need some help with the following problem. I just can't figure it out (and yes I did the googlework etc).
Using csh I need to read one line from a file (there is only 1 line in the file), split it into separate strings (!not every value is separated with a space, however they do have a fixed position (always in the 3rd and 4th field)) and assign two of them to two separate variables in long format (so no E+04). The two values of interest are:
82390.43500000000
and
4.167000000000000
(so without the 'Earth' attached to it).
They need to be assigned to respectively time
and time_step
.
The inputfile temp.txt looks like:
000520000001 260026 8.239043500000000E+04 4.167000000000000E+00Earth Centred Rotating -9.999999999999998E+03-9999999.9999999-9999999.9999999-9999999.9999999
There are multiple files called temp.txt, however placed in different folders. The only part that stays constant in all files is Earth Centred Rotating.
What is the best way to do this (awk/grep/sed/?)?
Thanks!
Upvotes: 0
Views: 221
Reputation: 2253
awk '{sub(/E.*/,"",$3); print$3}' temp.txt
and
awk '{sub(/E.*/,"",$4); print$4}' temp.txt
gives 82390.43500000000 and 4.167000000000000 respectively which can then be assigned to your variables.
Upvotes: 1