Re: cat and grep without destroying file



(``-_-´´) -- Fernando wrote:
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, some how. I have never successfully done it without
an mv or a cp.

Chris


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



Relevant Pages

  • Re: tail -f with the Bell sound
    ... I have written a script with tail -f filename | grep `xxx xx` and I ... I am not sure if I can pipe the awk again after the grep. ...
    (comp.unix.shell)
  • Re: tell me how many specific words there are in the file?
    ... I'm trying to get the user to enter a word, then the script should ... Pipe to grep ... then pipe to wc. ... Rouben Rostamian ...
    (comp.unix.programmer)
  • Re: tail -f with the Bell sound
    ... I have written a script with tail -f filename | grep `xxx xx` and I ... I am not sure if I can pipe the awk again after the grep. ...
    (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: want to ask how to use grep -v repeatly
    ... i am a new user for unix, and is writing a script for working purpose. ... could someone tell how can I "grep -v " more than a string in ... a command, cause the machine i'm using is very busy. ... when I pipe the ...
    (comp.unix.shell)