cat and grep without destroying file



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?

--
BUGabundo :o)
(``-_-´´) http://Ubuntu.BUGabundo.net
Linux user #443786 GPG key 1024D/A1784EBB
My new micro-blog @ http://BUGabundo.net

Attachment: signature.asc
Description: This is a digitally signed message part.

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


Relevant Pages

  • Re: Transpose Column to Row Using Shell Script(Cygwin)
    ... > How can I Transpose Column to Row Using Shell Script? ... you are back to your original file;-) ... so the natural method with 'tr' is probably better... ...
    (comp.unix.shell)
  • append each line in a file with some extension
    ... records are names.Now I need to create file with a extension appended ... to each record in the original file. ... Could somebody tell me how to write a shell script for this.. ...
    (comp.unix.shell)
  • csh shell script situation
    ... execution of script doesnt complete ... I've included shell script below: ... setenv PIPE $home/trainrefresh/trainrefresh_ora.dmp ... In essence I'm trying to dump file content into pipe then have Oracle ...
    (comp.unix.shell)
  • Re: Piping into a shell script
    ... > I want to write a shell script in bash, where I can pipe other commands ...
    (comp.os.linux.misc)
  • Re: stdout buffer in pipe filled up
    ... > CT> My program creates a pipe and then forks to create a child. ... > CT> The child reads from a shell script and puts it to the stdout and the ... > CT> is more than 9K, the waitid() is hanging, waiting for the child to ...
    (comp.unix.programmer)