| Redirect to the same file [message #161866] |
Tue, 07 March 2006 10:05  |
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
|
|
|
| Re: Redirect to the same file [message #162121 is a reply to message #161866 ] |
Wed, 08 March 2006 19:11  |
rleishman Messages: 3118 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
|
|
|