Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ways to clean a file

Status
Not open for further replies.

rogsal

Programmer
May 12, 2004
10
0
0
SE
Hi!

Normally when I want to delete everything in a file without deleting the file itself I do:
# >filename

However this doesnt work well when combinig it with rsh calls:
# rsh loghost >/var/adm/logfile
which will create a file on my local machine and then just hangs there...

To make it even more difficult I have to do it in two steps:
# rsh server rsh xstation >/var/adm/logfile

And finally to make it almost impossible, the log rotates and gets a number at the end which differs every time my script runs:
# rsh server rsh xstation >/var/adm/logfile.???

So, is there another command besides '>' that emptys a file??

regards
Roger
 
Not sure if this will help, but touch <file> is (AFAIK) the equivalent of > in this context.
 
But touch would just update the date on the file not remove its content...
 
No problem.... I'll fixed it with
cat /dev/null > filename
 
Hi.
Roger, you may use your original syntax too:
Code:
rsh loghost ">/var/adm/logfile"
Without the quotes you redirect output of rsh.

Stefan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top