On 26/05/2006, at 10:43 PM, Robert Thorsby wrote:

On 2006.05.26 22:34 Sam Lawrance wrote:
The argument for "-i" is optional; if supplied sed provides a backup; if not supplied sed amends the input file. See "man sed"
That is ridiculous. Unless you know in advance what the argument will be, it is not possible to detect that it has not been supplied.

Look, I don't know whether it is ridiculous or not. I use "sed -i" simpliciter often from the command line to wipe all text from a file:
sed -i 'd' input.file

I apologise, that wasn't called for. I think I see what version you are using - it seems that you can't have a space between -i and its argument. It's behaviour I have not seen before (SUS suggests that it is non-portable, too :).

It works for me; YMMV. I do, however, suggest you RTFM. The man page is quite clear

I did.  It is.  My man page is not your man page ;-)

Anyhow, my main point is that any form of '-i' is a nonstandard extension.

In the context of the request I did not think that portability was an issue. If it were, then clearly something more than my Q&D command one-liner might be desirable.

Portability is never an issue. Until you try to run your stuff on some other platform. Take it from someone who likes to patch the linuxisms out of software for fun.


--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to