To add lines to a file with sed, use the backslash to escape your newline character and continue with the replacement string on the next line. sed 's/$/\ COMMIT/' input.file > output.file =========================================================================== Here's a rather complicated, but educational sed string that I typed in at the command line to change a file with lines like db2 "delete from main where patn = 'D381785' " to append an if rc<>0 blah blah blah statement on each line, like so db2 "delete from main where patn = 'D381785' ";src=$?;if (( $src ));then echo "Error ($src) deleting D381785";fi (That's 1 big, long line) The input file was raj2, the output file was raj3 sed 's/'"'"'\(.*\)'"'"' "$/'"'"'\1'"'"' ";src=$?;if (( $src ));then echo "Error ($src) deleting \1";fi/' raj3 The interesting points to this sed command are - Getting a single quote into the sed command. You can't get a single quote within single quotes (ksh book, page 133). Thus every time I need a real single quote, I stop the single-quoted string, then append a "'", then restart the single-quoted string again. Whew! This was done four times. - The use of pattern matching. Delimit the pattern with \( and \), and use the pattern with \1. The pattern I was looking for was the patent number (D381785 in the example line), which was used twice in the replace-with string. - I also had to save the $? return code for the error message, since the (( ... )) test, itself changes $?. ===========================================================================