joining two lines

Hi ,

I want to join two lines in a file, where the second line contain query string. if it doesn't contain that string i don't want to join
e.g.
Input file is as following:

name fame game
none none none
name fame game
cat eat mice

I need output file as

name fame game
none none none
name fame game cat eat mice

How can it be done using awk or sed?

At first: Use CODE-tags when you post code, data or logs for better readability, ty.

awk '!/mice/ {l=$0; getline; if($0 ~ /mice/){print l,$0} else{print l"\n"$0} }' infile
name fame game
none none none
name fame game cat eat mice

Thankx zaxxon, it works :slight_smile: