On Wed, Jan 07, 2004 at 12:42:33PM -0600, Rick Weinbender wrote: > Is there a command to flush or empty the contents > of a file? > I would like the empty file to retain it's attributes and rights.
I don't know about a program, but this is how to do it in perl:
#!/usr/bin/perl
if(!$ARGV[0]){
print "Usage: $0 [files].\n";
exit;
}
foreach $file (@ARGV){
if(-f $file){
open(IN,">$file");
close(IN);
}
else{
print "The file $file doesn't exist.\n";
}
}
the '>' in the call to open causes it to truncate the file.
Just copy that to /usr/local/bin/truncate or wherever :)
Bijan
--
Bijan Soleymani <[EMAIL PROTECTED]>
http://www.crasseux.com
signature.asc
Description: Digital signature

