echo "$(cat bigfile)" | sed s/foo/bar/ > bigfile # is this safe?

echo "$(cat bigfile)" | sed s/foo/bar/ > bigfile # is this safe?

Post by Tom Rodma » Sat, 23 Nov 2002 00:48:12



--
Tom Rodman
perl -e 'print unpack("u", "\.\=\$\!T\<F\]D\;6\%N\+F\-O\;0H\`");'
 
 
 

echo "$(cat bigfile)" | sed s/foo/bar/ > bigfile # is this safe?

Post by Tom Rodma » Fri, 22 Nov 2002 23:59:43


--
Tom Rodman
perl -e 'print unpack("u", "\.\=\$\!T\<F\]D\;6\%N\+F\-O\;0H\`");'

 
 
 

echo "$(cat bigfile)" | sed s/foo/bar/ > bigfile # is this safe?

Post by Paul D. Smit » Sat, 23 Nov 2002 02:13:14


--
-------------------------------------------------------------------------------

 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.

 
 
 

echo "$(cat bigfile)" | sed s/foo/bar/ > bigfile # is this safe?

Post by Bruce Burhan » Sat, 23 Nov 2002 03:14:36




Quote:

> --
> --------------------------------------------------------------------------

-----

:-)  :-)

Bruce
--
     Bellingham   Washington   USA
     bburhan1  [ AT]   earthlink  [ DOT]  net


Tools
>  "Please remain calm...I may be mad, but I am a professional." --Mad
Scientist
> --------------------------------------------------------------------------
-----
>    These are my opinions---Nortel Networks takes no responsibility for

them.
 
 
 

echo "$(cat bigfile)" | sed s/foo/bar/ > bigfile # is this safe?

Post by Andreas K?h?r » Sat, 23 Nov 2002 05:30:12


Submitted by "Tom Rodman" to comp.unix.shell:

Quote:

> echo "$(cat bigfile)" | sed s/foo/bar/ > bigfile # is this
> safe?

No.  The different parts of the pipeline starts up independently
of each other.  If the second part starts before the first part,
the first thing it will do is to truncate 'bigfile'.

sed 's/foo/bar/' bigfile >bigfile.new
mv bigfile.new bigfile

That's a command less, uses less memory, and is perfectly safe.

--
Andreas K?h?ri               --==::{ Have a Unix: netbsd.org
                             --==::{ This post ends with :wq

 
 
 

1. why "" in echo "$FOO" ?

I just read in a book that to one way to find out the value of an
enviroment variable is to give it as the argument to echo, preceded
by a $ and surrounded by double quotes, as in echo "$FOO".  Why
the quotes?  It seems that I get the same results whether I do echo
$FOO or echo "$FOO".

Thanks!

        Karl

--
Sent from a spam-bucket account; I check it once in a blue moon.  If
you still want to e-mail me, cut out the extension from my address,
and make the obvious substitutions on what's left.

2. physical and Vurtual memory usage in solaris 8

3. cat foo* > foo.bar causes infinite loop

4. e2fsck causing crash due to corrupt FS

5. 'echo "some text" |read foo' results in empty $foo

6. ISAM error

7. What is the diff. between "sh foo" and "foo"?

8. Setting up POP users

9. What is the meaning of "foo" and $foo"?

10. foo=X%XY%Z; echo ${foo//X/w} works;echo ${foo//%%/p} NotWhatIwant

11. Solaris 8 box: cat file | rsh solaris_2.6_box "cat > /dev/null" SLOW

12. Type 'yes > bigfile &' on your system

13. GETSERVBYNAME()????????????????????"""""""""""""