Quantcast
Channel: Commands tagged dates sorted by votes
Viewing latest article 9
Browse Latest Browse All 10

Prepend section dates to individual entries in a summary log file

$
0
0
$ gawk 'match($0, /^\s*([0-9]{2}\/[0-9]{2}\/[0-9]{4})\s*/, m) {prev_date=m[1]} /SEARCHSTRING/ {print prev_date, ",", $1 $2, ",", $3, "," $5}' inputfile.txt
Searches for dates on lines by themselves. Uses that date to prepend all rows that contain SEARCHSTRING with the date, until it reaches another line with a date by itself. This fixed an issue with a specific log export where there would be a date, followed by all of the entries for that date.

commandlinefu.com

Diff your entire server config at ScriptRock.com


Viewing latest article 9
Browse Latest Browse All 10

Trending Articles