cat and grep without destroying file

(=?utf-8?q?=60=60-=5F-=C2=B4=C2=B4?=) -- Fernando ubuntu at bugabundo.net
Mon Oct 1 23:34:46 UTC 2007


On Sunday 30 September 2007 15:27:15 Chris Malton wrote:
> (``-_-´´) -- 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

Thanks, Chris.

-- 
BUGabundo  :o)
(``-_-´´)	http://Ubuntu.BUGabundo.net
Linux user #443786    GPG key 1024D/A1784EBB
My new micro-blog @ http://BUGabundo.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20071002/840dc046/attachment.sig>


More information about the ubuntu-users mailing list