Reputation: 15
this is the data file I have and I want below output How can I achieve it.
07:15:01 ST go-b-s1 07:15:21 FA go-b-s1 07:15:22 FA go-a-s1 07:15:01 ST go-c-s2 07:15:21 FA go-c-s2 output how to get below output using awk or sed 07:15:01 ST go-b-s1 07:15:21 FA go-b-s1 07:15:22 FA go-a-s1 07:15:01 ST go-c-s2 07:15:21 FA go-c-s2
Upvotes: 0
Views: 56
Reputation: 212238
It looks like you just want to trim the newline from lines that have ST
in the second column. If that's the case:
awk '$2 == "ST" { printf "%s ", $0; next} 1' input-file
Other options:
sed '/ST/{ N; s/\n/ /; }' input-file
perl -pe 's/\n/ / if /ST/' input-file
It's difficult to tell what you actually want with just one sample. It is generally a good idea to at least attempt to describe how you want to manipulate the data.
Upvotes: 1