sed: how to search for string and insert a line AFTER

JCTDD
JCTDD used Ask the Experts™
on
I have a large number of inputfile.txt files that looks like this:

abcdef
ghijk
lmnopq

I would like to SEARCH for the pattern 'abc' and insert a line 'xyz' such that outputfile.txt should now look like:

abcdef
xyz
ghijk
lmnopq

I'm reading thru: http://www.grymoire.com/Unix/Sed.html
but i'm having difficulties because the author suddenly switches his examples from the command line to shell script.

I want an example that works from the command line.

sed 'a/abc/xyz' < inputfile.txt > outputfile.txt
sed: command garbled:

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
try:

sed -e "/abc/axyz" < inputfile

Author

Commented:
That did not work. Command garbled.

Commented:
This seems solaris specific;

try to add a \ and a new line after the "a":

sed -e "/abc/a\
xyz" < inputfile
Commented:
The problem has been fixed by following the example here:

http://www.linuxjournal.com/article/7231

Thanks for everyone's input.
Dirk HaestProject manager

Commented:
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial