I have a file with number of lines containing time stamps and few lines in between. For example,
TIMESTAMP MESSAGE
TRAIL 1
TRAIL 2
TIMESTAMP MESSAGE2
TRAIL 21
TRAIL 22 ...
I want to add all trail messages into a single line, or better yet all lines between two time stamps to get into a single line, so that my output would look something like
TIMESTAMP MESSAGE TRAIL 1 TRAIL 2
TIMESTAMP MESSAGE2 TRAIL 21 TRAIL 22 ...
I went through few questions here which are similar but none worked in my case. I tried using
sed -i '/pattern_for_timestamp/{n;:l N;/pattern_for_timestamp/b ; s/\n// ; bl}'
but it only changes every alternative occurrence of the pattern. There need not be any pattern in the trail messages. I would prefer using sed or awk in this case.
Aucun commentaire:
Enregistrer un commentaire