0

I have the following output and am trying to extract the following values:

Date (X) and Value (Y), with each data point labeled by step number.

Here is the output:

Profiling step 1 @ 2016-08-31 11:58:56.344464+00:00 $1 170.58984375
Profiling step 2 @ 2016-08-31 12:02:10.958859+00:00 $2 3361.6328125
Profiling step 3 @ 2016-08-31 12:02:14.387444+00:00 $3 3361.0546875
Profiling step 4 @ 2016-08-31 12:03:53.674385+00:00 $4 4508.9765625
Profiling step 5 @ 2016-08-31 12:05:15.625707+00:00 $5 5487.6484375
Profiling step 6 @ 2016-08-31 12:05:24.167411+00:00 $6 5558.91796875
Profiling step 7 @ 2016-08-31 12:05:26.981129+00:00 $7 5582.12890625
Profiling step 8 @ 2016-08-31 12:05:30.468513+00:00 $8 5609.92578125
Profiling step 9 @ 2016-08-31 12:05:37.910140+00:00 $9 5673.94921875

So far I have been able to extract Step and Value which come after $, eg. 1 170.589843, etc with the following command:

grep -o '$[^,]*'

Output:

$1 170.58984375
$2 3361.6328125
$3 3361.0546875
$4 4508.9765625
$5 5487.6484375
$6 5558.91796875
$7 5582.12890625
$8 5609.92578125
$9 5673.94921875

Desired output:

2016-08-31 11:58:56.344464 170.58984375 1
2016-08-31 12:02:10.958859 3361.6328125 2
2016-08-31 12:02:14.387444 3361.0546875 3
etc..

Any help? Thanks

2
  • 1
    can you please post your expected output ?
    – Rahul
    Commented Aug 31, 2016 at 12:18
  • Apologies, I realised I left that out and just edited the original post. Thanks
    – gti106
    Commented Aug 31, 2016 at 12:20

1 Answer 1

1
$ awk '{sub(/[+-].*/,"",$6); print $5,$6,$8,$3}' file
2016-08-31 11:58:56.344464 170.58984375 1
2016-08-31 12:02:10.958859 3361.6328125 2
2016-08-31 12:02:14.387444 3361.0546875 3
2016-08-31 12:03:53.674385 4508.9765625 4
2016-08-31 12:05:15.625707 5487.6484375 5
2016-08-31 12:05:24.167411 5558.91796875 6
2016-08-31 12:05:26.981129 5582.12890625 7
2016-08-31 12:05:30.468513 5609.92578125 8
2016-08-31 12:05:37.910140 5673.94921875 9

(the sub just trims the timezone; you may omit it if you don't need to do that).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .