Home » Infrastructure » Unix » Redirect to the same file
Redirect to the same file [message #161866] Tue, 07 March 2006 10:05 Go to next message
Daxesh
Messages: 61
Registered: July 2004
Member
Hello Friends,

I have really simple question on Unix.

I have one big file (test1.txt). Now I want to keep last 10 lines from this file with the same file name.

I was thinking to do like this

tail -10 test1.txt > test1.txt

But in this case my file size become '0'

Is there a way to do this?

Thanks again Mad
Re: Redirect to the same file [message #162121 is a reply to message #161866] Wed, 08 March 2006 19:11 Go to previous message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
Not the way you want. Best way is:

tail -10 test1.txt > .tmp.test1.txt && mv .tmp.test1.txt test1.txt 


_____________
Ross Leishman
Previous Topic: why unix is preferred
Next Topic: Displaying LONG Type columns using SQL
Goto Forum:
  


Current Time: Tue Apr 16 00:08:25 CDT 2024