If you can use awk, you can do:
gawk '{if ($0 ~ /^@/ ) { print ; getline ; print ; getline ; print "+"}}' INPUTFILE
So, if gawk sees @ at the beginning of the line, it will be printed, then the next line will be split && & printed and finally the 3rd line (after @ ) will be punched and only + printed.
If + not at the beginning of the line, you can use gensub(/\+.*/,"+",$0) instead of "+" in the last print .
(And if you have perl installed, most likely there will be an a2p , which can convert the above awk script to perl if you want ...)
NTN
UPDATE (4th line missing):
gawk '{if ($0 ~ /^@/ ) { print ; getline ; print ; getline ; print "+"; getline; print }}' INPUTFILE
This should also print 4th line.
source share