* Dan Ray <[EMAIL PROTECTED]> [010710 06:14]:
> Well, it's just been pointed out that it doesn't actually EMPTY the file per
> se. It actually creates a one-byte file. I believe that the 'echo' command
> prints the string argument given it, plus a newline on the end. That newline
> gets into the new file, so you actually have a file that isn't empty, but
> contains a single newline character.
>
> As long as you don't actually need this file to be totally emptied to zero
> bytes, and don't mind a blank line at the top of the file, this should work
> fine. I haven't seen the permissions issue that Jose mentions at all, in all
> my fooling with this the permissions are preserved. So maybe he's seeing
> something we're not.
As Ray says, the
echo > myfile
method works fine regarding ownership and permissions, but leaves a
newline in the file. If you want a zero-length file, why not:
echo -n > myfile
this tells 'echo' not to follow the (empty) string with a newline, so
the resulting file is zero length. I just tested this on Mdk 8.0 to
be sure.
--
Jan Wilson, SysAdmin _/*]; [EMAIL PROTECTED]
Corozal Junior College | |:' corozal.com corozal.bz
Corozal Town, Belize | /' chetumal.com & linux.bz
Reg. Linux user #151611 |_/ Network, SQL, Perl, HTML