Skip to content
Advertisement

How to add text at the end of each line after skipping Last N characters

I’m on Linux command line and I have log file with following content

JavaScript

I want to add date before Time Stamp for every line

JavaScript

Advertisement

Answer

Something like this:

sed -r “s/([0-9]+{1}:[0-9]+{1}[A-Z]{2}.*$)/01 Oct 2016 1/g” test.txt > new.txt

Where text.txt is your log file and “01 Oct 2016 ” is your text and the 1 is the time inserted back in from the group match.

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