Re: truncating files
-----BEGIN PGP SIGNED MESSAGE-----
Carl Mummert <email@example.com> writes:
> Is there already a (standard) utility on a linux box to truncate a
> file to 0 bytes? [Besides echo -n "" > foo, which is 1) too long for
> my lazy fingers and 2) won't take multiple filenames ]
> Since I couldn't find one, I wrote a little C program to do it, but I
> am still interested in whether there is already one on the system.
Other users have suggested the use of "> foo", a "null command", but
that does not work in tcsh, my preferred shell. Note that "echo > z"
does not, as you might expect it to, add a blank line (at least under
tcsh). So you can save 5 characters from your example that way.
However the way I do this is by doing "cp /dev/null foo"... I don't
remember why but this is supposedly a better way of doing it. I think
it preserves the file permissions more accurately? I am not sure.
I picked that up years ago but have since forgotten the reason...
William R Ward Bay View Consulting http://www.bayview.com/~hermit/
firstname.lastname@example.org 1803 Mission St. #339 voicemail +1 408/479-4072
email@example.com Santa Cruz CA 95060 USA pager +1 408/458-8862
-----BEGIN PGP SIGNATURE-----
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface
-----END PGP SIGNATURE-----
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
Trouble? e-mail to firstname.lastname@example.org .