Re: cat and grep without destroying file



Am Fri, 28 Sep 2007 14:22:13 +0100
schrieb "(``-_-´´) -- Fernando" <ubuntu@xxxxxxxxxxxxx>:

I've been trying to make a small shell script that would remove a
line from a text file. But every time that I pipe the content of grep
to the original file, the file ends up blank. So, I've made the
script use a copy and them replace the original. It looks like this:
#for i in $(/bin/ls -1); do cat $i | egrep -v ^Date > $i.new; mv
$i.new $i; done

Isn't there any other way, without using the mv?

I don't think so, but there is no reason to use cat.
#for i in $(/bin/ls -1); do egrep -v ^Date < $i > $i.new; mv $i.new $i;
done

Gerald

--
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users


Relevant Pages

  • Re: file processing
    ... > original file, just i am interested in doing this w/o having to change ... > can grep for that easily enough. ... >> (not presented as a working script, ... > still be interested in an awk solution. ...
    (comp.unix.shell)
  • Re: file processing
    ... > I've been playing with this and am just going to share what I've come up ... original file, just i am interested in doing this w/o having to change ... can grep for that easily enough. ... > (not presented as a working script, ...
    (comp.unix.shell)
  • Re: cat and grep without destroying file
    ... But every time that I pipe the content of grep to the original file, ... I've made the script use a copy and them replace the original. ...
    (Ubuntu)
  • Re: cat and grep without destroying file
    ... But every time that I pipe the content of grep to the original file, ... I've made the script use a copy and them replace the original. ...
    (Ubuntu)
  • Re: cat and grep without destroying file
    ... On Sunday 30 September 2007 15:27:15 Chris Malton wrote: ... But every time that I pipe the content of grep to the original file, ...
    (Ubuntu)