[H-GEN] sed query

Paul Gearon pag at PISoftware.com
Tue May 6 23:09:23 EDT 2003


[ Humbug *General* list - semi-serious discussions about Humbug and     ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]

On Wed, 7 May 2003, Greg Black wrote:

> On 2003-05-06, Scott Pullen wrote:
> > sed -e 's/SOMETEXT/\n SOMETEXT/g' > output.txt
> >
> > the output file is empty.
>
> I find it extremely difficult to believe that -- using the exact
> command line shown -- the output file would be empty.

It will if nothing is piped into the sed command.  That's probably not
happening with Scott's real command, but the "exact command line shown" is
reading from stdin.

>     $ sed 's/ /
>     > /g' < input_file
>
> The "> " is $PS2 in my shell; the newline is a literal newline.
> This will always work (except where bugs in sed or unparseable
> input cause it to fail).

Actually, you need a \ before the newline, otherwise you get an
"Unterminated `s' command".  OTOH, that's bash, and it's been too long
since I've used any other shell to remember the differences, so maybe this
works on other shells.
<grin mode="sheepish"/>

<snip/>
> If you don't have a "real editor" (e.g., emacs)...

Oh no, you're not trying to open THAT can of worms again, are you?  I'm
getting sick of the "my editor is better than yours" arguments which start
with pejorative comments like this.  VI (the editor mentioned in Scott's
email) can do whatever you want as well (including this).  It's not better
or worse, just different.

Regards,
Paul Gearon

Software Engineer                Telephone:   +61 7 3876 2188
Plugged In Software              Fax:         +61 7 3876 4899
http://www.PIsoftware.com        PGP Key available via finger

Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum
immane mittam.
(Translation from latin: "I have a catapult. Give me all the money,
or I will fling an enormous rock at your head.")



--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.  See http://www.humbug.org.au/



More information about the General mailing list