Re: truncating files
On Sun, Dec 07, 1997 at 03:05:00PM -0500, Carl Mummert wrote: cmrm -f {list of filenames} cmtouch {list of filenames} This doesn't work if you don't have write permission to the directory. The solution should be able to truncate any file I have write access to, even if I can't write to the directory. Are you sure you should be doing this, then? Hamish -- Hamish Moffatt, [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] Latest Debian packages at ftp://ftp.rising.com.au/pub/hamish. PGP#EFA6B9D5 CCs of replies from mailing lists are welcome. http://hamish.home.ml.org -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] .
Re: truncating files
From the bash manpage: noclobber If set, bash does not overwrite an existing file with the , , and redirection operators. This variable may be overridden when creating output files by using the redirection operator | instead of (see also the -C option to the set builtin command). Bob On Sun, 7 Dec 1997,William R Ward [EMAIL PROTECTED] wrote: 1) I use set -C in bash, so I can't say foo if foo exists wthout first saying set +C. | foo overrides the noclobber option Don't you mean !, not |?? -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] .
Re: truncating files
A very simple way is foo (noquotes) works in bash. It also creates a file. Krzysztof On Sat, 6 Dec 1997, Carl Mummert wrote: 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. Carl [EMAIL PROTECTED] One must imagine Sysiphus happy -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] . -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] .
Re: truncating files
-BEGIN PGP SIGNED MESSAGE- Carl Mummert [EMAIL PROTECTED] 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... HTH. - --Bill. - -- William R Ward Bay View Consulting http://www.bayview.com/~hermit/ [EMAIL PROTECTED] 1803 Mission St. #339voicemail +1 408/479-4072 [EMAIL PROTECTED] Santa Cruz CA 95060 USA pager +1 408/458-8862 -BEGIN PGP SIGNATURE- Version: 2.6.2 Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface iQCVAwUBNIo/lR25V7Ur0zHlAQHVUQP/cX0J9D6OFRmON4k4CM8Ah8lmePipA7O6 6nlSc3ibyfbQHAsf3mxhVNOPx/QhBxFafEwFE905OLx5PJQpePIkF12BviQcjP86 /Z4l0VGHIM1fj0Vka6huMx9ShhVLZZHeNMcQq4SM2kDYHX3oWD0LScr3zZadFTMe MN0hsbhtLXo= =S+BB -END PGP SIGNATURE- -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] .
Re: truncating files
-BEGIN PGP SIGNED MESSAGE- Carl Mummert [EMAIL PROTECTED] 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... HTH. - --Bill. - -- William R Ward Bay View Consulting http://www.bayview.com/~hermit/ [EMAIL PROTECTED] 1803 Mission St. #339voicemail +1 408/479-4072 [EMAIL PROTECTED] Santa Cruz CA 95060 USA pager +1 408/458-8862 -BEGIN PGP SIGNATURE- Version: 2.6.2 Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface iQCVAwUBNIo/lR25V7Ur0zHlAQHVUQP/cX0J9D6OFRmON4k4CM8Ah8lmePipA7O6 6nlSc3ibyfbQHAsf3mxhVNOPx/QhBxFafEwFE905OLx5PJQpePIkF12BviQcjP86 /Z4l0VGHIM1fj0Vka6huMx9ShhVLZZHeNMcQq4SM2kDYHX3oWD0LScr3zZadFTMe MN0hsbhtLXo= =S+BB -END PGP SIGNATURE- -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] . -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] .
Re: truncating files
Summary: 1) foo 2) cp /dev/null foo Problems: 1) I use set -C in bash, so I can't say foo if foo exists wthout first saying set +C. 2) cp /dev/null foo won't take multiple filenames as arguments So teh answer is that I do need a script or program to do the job. Carl [EMAIL PROTECTED] One must imagine Sysiphus happy -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] .
Re: truncating files
On Sun, 7 Dec 1997, Carl Mummert wrote: Summary: 1) foo 2) cp /dev/null foo Problems: 2) cp /dev/null foo won't take multiple filenames as arguments So the answer is that I do need a script or program to do the job. What about: rm -f {list of filenames} touch {list of filenames} ...RickM... -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] .
Re: truncating files
cm cm 1) foo cm 2) cp /dev/null foo cm cm Problems: cm cm 2) cp /dev/null foo won't take multiple filenames as arguments cm cm So the answer is that I do need a script or program to do the job. cm cmWhat about: cm cmrm -f {list of filenames} cmtouch {list of filenames} This doesn't work if you don't have write permission to the directory. The solution should be able to truncate any file I have write access to, even if I can't write to the directory. Otherwise rm -f / touch would be ok. Carl [EMAIL PROTECTED] One must imagine Sysiphus happy -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] .
Re: truncating files
1) I use set -C in bash, so I can't say foo if foo exists wthout first saying set +C. | foo overrides the noclobber option Bob -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] .
Re: truncating files
The problem with removing and recreating is that if a program has that file open for appending (e.g. logfiles), the file isn't actually removed from the disk until that program closes its file descriptor. So you end up with 3 problems: 1. The file still exists on disk, but is not linked to in any directory; 2. New log messages are sent to the phantom file, not to your newly created file - so you never see them; and 3. You lose the file ownership and permissions of the original file. --Bill. In article [EMAIL PROTECTED], Rick Macdonald [EMAIL PROTECTED] writes: On Sun, 7 Dec 1997, Carl Mummert wrote: Summary: 1) foo 2) cp /dev/null foo Problems: 2) cp /dev/null foo won't take multiple filenames as arguments So the answer is that I do need a script or program to do the job. What about: rm -f {list of filenames} touch {list of filenames} ...RickM... -- William R Ward Bay View Consulting http://www.bayview.com/~hermit/ [EMAIL PROTECTED] 1803 Mission St. #339voicemail +1 408/479-4072 [EMAIL PROTECTED] Santa Cruz CA 95060 USA pager +1 408/458-8862 -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] .
Re: truncating files
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Robert D. Hilliard) writes: 1) I use set -C in bash, so I can't say foo if foo exists wthout first saying set +C. | foo overrides the noclobber option Don't you mean !, not |?? --Bill. -- William R Ward Bay View Consulting http://www.bayview.com/~hermit/ [EMAIL PROTECTED] 1803 Mission St. #339voicemail +1 408/479-4072 [EMAIL PROTECTED] Santa Cruz CA 95060 USA pager +1 408/458-8862 -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] .
Re: truncating files
In article [EMAIL PROTECTED], Carl Mummert [EMAIL PROTECTED] wrote: 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 ] Yeah, just use filename eg, the null command. If you find this unreadable you can also use : filename 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. Multiple filenames? for i in *; do : $i; done Mike. -- Miquel van Smoorenburg | Studying to be a technomage * [EMAIL PROTECTED] | May you live in interesting times -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] .
RE: truncating files
Try this one: foo or, for multiple file names: for xxx in * do $xxx done where * is any regular expression or: for xxx in a b c d e f g.c h.o g.txt ... do $xxx done If your finger are lazier than that, I'm afraid I can't help ;-) On 06-Dec-97 Carl Mummert wrote: 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. Carl [EMAIL PROTECTED] One must imagine Sysiphus happy -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] . - Ralph Winslow [EMAIL PROTECTED] The IQ of the group is that of the member whose IQ is lowest divided by the number of members. -- TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to [EMAIL PROTECTED] . Trouble? e-mail to [EMAIL PROTECTED] .