Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] sed / shell / redirection question



On Sun, 06 May 2007 23:04:40 +0900, Mark Makdad <mark@example.com>
wrote:

> My question is:
>
> Why did this take all of my input files and truncate them at zero
> bytes?

Because the command is handled this way:

1) The shell sets up a file descriptor to suck up the output from sed
while it's running. In doing so, it opens the file for output, thus
truncating it.

2) The shell starts sed and funnels its output through the file
descriptor it created in the previous step.

3) sed opens the file for input, sees it is empty and stops there and
then.

> Am I screwing up a basic redirection thing there?

Yes. You don't need it.

Look at sed's -i option in the man page.

--
G. Stewart - gstewart@example.com

"Our enemies are innovative and resourceful, and so are we. They never
 stop thinking about new ways to harm our country and our people, and
 neither do we."
       -- President George W. Bush addressing the Pentagon, 05-AUG-2004

Attachment: pgpwfuZsZP1Zx.pgp
Description: PGP signature


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links