sed question
Jerry Peek
jerryp at tektools.UUCP
Tue Oct 1 01:15:38 AEST 1985
In article <1492 at uwmacc.UUCP> jwp at uwmacc.UUCP (Jeffrey W Percival) writes:
> sed(1) allows you to give the script on the command line like this:
>
> sed -e 'script' file1 > file2
>
> Some of the sed commands, like a\ and i\ seem to need additional
> lines of input. I know that if I use the "-f sedfile" option I
> can stash the commands in a file, but is there a way I can use
> "append" and "insert" with the -e option?
Yes, but the way you do it depends on which shell you're using.
For example, in Bourne or Korn shells, you can do:
$ sed -e '1a\
> hi\
> there' file1 > file2
$
(the >'s are Bourne-shell secondary prompts).
To avoid "Unmatched '." errors in the C-shell, you have to use extra
backslashes:
% sed -e '1a\\
hi\\
there' file1 > file2
%
(in this case, csh won't give a secondary prompt).
--Jerry Peek, UNIX Training Instructor, Tektronix, Inc.
US Mail: MS 74-222, P.O. Box 500, Beaverton, OR 97077
uucp: {allegra,decvax,hplabs,ihnp4,ucbvax}!tektronix!tektools!jerryp
CS,ARPAnet: jerryp%tektools at tektronix.csnet
Phone: 503/627-1603
More information about the Comp.unix
mailing list