Reputation: 175
I want to merge specific line
Input :
AAA
BBB
CCC
DDD
EEE
AAA
BBB
DDD
CCC
EEE
Output Should be
AAA
BBB
CCC DDD
EEE
AAA
BBB
DDD
CCC EEE
I want to search CCC and merge next line with it.
I have tried with awk command but didn't get success
Upvotes: 1
Views: 103
Reputation: 13220
Use awk patterns, if the line matches /CCC/
then print the line with a space at the end and go on to the next line. Otherwise (1
), print the line.
awk '/CCC/ { printf("%s ", $0); next } 1' file
Upvotes: 2