Skip to content
Advertisement

Insert space between numbers after matching specific pattern [closed]

I have the following temperature data that needs to be manipulated. Thought about using sed to insert a space in between the data but, the data is changing constantly.

JavaScript

I need it to look like this:

JavaScript

Right now, I am using the following code to parse out the highest value (where the numbers are clustered together):

JavaScript

Advertisement

Answer

The first thing to do would be to modify whatever it is that generates the data so that it outputs it with a wider field width.

If that’s not possible, then the following will de-mangle the output:

JavaScript

I put the tr at the end just to remove consecutive whitespaces in the output from sed (generated for all two-digit integers, except for the first one which, in this case, isn’t matched by the regular expression).

But really, the generator of the data will need to be updated.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement