sed script to add >'s to quoted text
4197,ATTT
rbr at bonnie.ATT.COM
Sun Feb 24 03:05:36 AEST 1991
In article <Feb.23.10.31.33.1991.12538 at pilot.njin.net> dblack at pilot.njin.net (David Alan Black) writes:
>I am trying to devise a simple shell script to add ">" to the beginning of
>every line of a text file containing an article or letter which I wish to
>quote in my response.
>
>Can someone please explain why the following doesn't work (I'll reproduce
>the whole session):
>
>pilot% cat > quote
>sed s/^/\>/ -e $1 > $1.quoted
>^D
>pilot% chmod a+x quote
>pilot% quote friend.letter
>quote: />/: not found
>pilot% sed: Illegal or missing delimiter: s/
>
> Mrs. Emma Peel
Your problem is that the shell can see the \> which it takes as a
literal and redirection. Try this:
cat >quote <<EOD
sed -e "s/^/\\>/" $1 >$1.quoted
EOD
quote letter
Note "-e" is not a switch, it is a non-positional command line
parameter. An edit script must follow it.
Hope this helps.
Bob Rager
Ain't no place like ${HOME}.
More information about the Comp.unix.shell
mailing list