Re: Redirecting the output to input file

From: Måns Rullgård (mru_at_inprovide.com)
Date: 02/16/05


Date: Wed, 16 Feb 2005 12:46:05 +0100

Kasper Dupont <kasperd@daimi.au.dk> writes:

> arun.kumar.varma@gmail.com wrote:
>>
>> In our environment, cat is not a built-in. It's the executable
>> /usr/bin/cat. So, still my doubt is not cleared.
>
> In that case I suggest you verify if the command "cat x > x"
> actually truncates the file. I guess it might truncate the
> file before calling cat, and by the time cat is called and
> print the error message the file has already been truncated.

The question is why cat even bothers to check.

-- 
Måns Rullgård
mru@inprovide.com


Relevant Pages

  • Re: what make this shell script unstable?
    ... One that runs cat that opens ... "abc" readonly, one that opens "abc" write-only with truncation ... Behavior may also depend on how your system truncates files. ...
    (comp.unix.shell)
  • Re: So nobody has any comments on anything today?
    ... Scared my cat. ... BTW, any way to see the whole mouseover ... It truncates at "benz..." ...
    (rec.arts.comics.strips)
  • Re: cut byte
    ... Peter Cheung writes: ... This truncates the input to 10 characters and then produces the 4th byte ... cat hd.img| cut -b 4 ...
    (comp.os.linux.misc)
  • Re: Redirecting the output to input file
    ... On 2005-02-16, Kasper Dupont wrote: ... > actually truncates the file. ... cat: x: input file is output file ... The shell opens/truncates the file, does a fork, dup's ...
    (comp.os.linux.development.apps)