I had posted a question on bash: insert a line after a pattern using gawk
How do I insert more than one line after a line containing a pattern?
I had posted a question on bash: insert a line after a pattern using gawk
How do I insert more than one line after a line containing a pattern?
String together your prints like awk '<condition>{print $0; print "222"; print "223"; print "224"}
Or use the newline character:
awk '<condition>{print $0"\nthis is a line\nthis is a secondline\nthis is a thirdline"}
I modified nm1
from 222 to 222\\n333
to add multiple lines at once (the command is from the answer of your original post )
awk '1; $1==nm2 && !a++ {print nm1}' nm1=222\\n333 nm2=22 file
output:
11
22
222
333
33
11
22
33