Re: I/O redirection problem

From: Chris F.A. Johnson (c.fa.johnson_at_rogers.com)
Date: 05/26/04


Date: 26 May 2004 11:47:22 GMT

On 2004-05-26, Krit Kasemosoth wrote:
> I have data file 'test.txt'. I want to search text in that file and
> store
> the result back to file 'test.txt'. The command that I execute is :
>
> cat test.txt | grep monday > test.txt
>
> I execute it on two machines that have same environment(same OS,
> shell and utilities version).
> The command work on one machine (result of execution store in
> 'test.txt') but not work on another machine ('test.txt' is empty).
>
> What are the possible factors that make the command work ?
> (Because the command redirect output back to original file
> which must can not work)

    I wouldn't count on it working every time (did you try it more
    than once?).

    Presumably it worked because the (normally unnecessary) cat had
    finished before the redirection was executed (perhaps because the
    file was still in the cache?).

> This is a information of my two machines :
>
> 1. SunOS dev_24 5.8 Generic_108528-21 sun4u sparc SUNW,UltraAX-i2
> 2. SunOS ceres 5.8 Generic_117000-01 sun4u sparc SUNW,Ultra-Enterprise

-- 
    Chris F.A. Johnson                  http://cfaj.freeshell.org/shell
    ===================================================================
    My code (if any) in this post is copyright 2004, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License


Relevant Pages

  • Re: Best way to store postfix data?
    ... with control logic in the same time as the old read one line, execute ... but there's some memory hog I've missed in there. ... that seems infinitely preferable to trying to store them inline ... Since I allow control routines, I have to execute at runtime, ...
    (microsoft.public.vc.mfc)
  • Re: is malloc thread-safe??
    ... Richard Tobin wrote: ... If two separate threads that share the variable both execute the ... it can do the "store", the second thread can load, add, and store, ... C on some systems), an implementation-dependent locking mechanism ...
    (comp.lang.c)
  • Re: Concurrencty violation with decimal type
    ... > The Update statement is generated by the CommandBuilder. ... > statement fails in code and gives the concurrency violation error. ... I think today I will try to just store it ... When I try to execute the update statement directly in the ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: extract values from a csv file
    ... The reason I asked to store the values into ... individual variables, because I need to execute another shell script ... line by line and store the values into variables and then execute the ...
    (comp.unix.shell)
  • Re: Concurrencty violation with decimal type
    ... The Update statement is generated by the CommandBuilder. ... I then login via TOAD and execute the statement. ... I have changed the variables I store CRRNT_ARFRM_HRS from decimal to double, ... when a decimal type field changes from ...
    (microsoft.public.dotnet.framework.adonet)