Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!wuarchive!bcm!convex!tchrist From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.unix.shell Subject: Re: sed script to add >'s to quoted text Keywords: sed shell Message-ID: <1991Feb23.171025.11959@convex.com> Date: 23 Feb 91 17:10:25 GMT References: <1991Feb23.160536.15413@cbnewsl.att.com> Sender: tchrist@convex.com (Tom Christiansen) Reply-To: tchrist@convex.COM (Tom Christiansen) Distribution: usa Organization: CONVEX Software Development, Richardson, TX Lines: 44 From the keyboard of rbr@bonnie.ATT.COM (Bob Rager): :In article dblack@pilot.njin.net (David Alan Black) writes: :>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/ :> :Your problem is that the shell can see the \> which it takes as a :literal and redirection. Try this: No, that's not why it doesn't work. It's the old shell interpreting ^ as a pipe. Quoting the whole thing works. #!/bin/sh sed 's/^/>/' -e $1 > $1.quoted Here's actually more what I use. I like filters better than programs that operate on fixed filenames. I also don't see why I should call the sh if I can avoid doing so (systems without #! are out of luck): #!/bin/sed -f s/^./> &/ Most mail readers and editors give you a way to this easily. For example, I'm an mh-and-vi kind of guy, so I've this binding set up in my .exrc: " caveat emptor: this line has been run through 'cat -v' map \r 1G/^-/^[:r!sed -e '1,/^$/d' -e 's/^./> &/' @ ^[/^-/^[j " read in @, quoted (for MH replies, who link @ to current file) I could have done it all in vi, but it ends up faster in sed. --tom -- "UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things." -- Doug Gwyn Tom Christiansen tchrist@convex.com convex!tchrist Brought to you by Super Global Mega Corp .com