[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Emptying files



> I need a utility that will take a list of files using standard wildcards
> and empty their contents, but not deleting them. Has anyone stumbled on
> something like this? Thanks a bunch.

Try the shell command echo:

	echo -n '' > file

This redirect the empty string into file. The option -n avoids
the default printed newline, so the file is really empty.

	for x in *.*
	do
		echo -n '' > $x
	done

does the trick for several files. Instead of *.* use the pattern you like.

For details:

	man bash

or the manpage of your favorite shell.

I hope you wanted not to get a more sophisticated utility.



Armin
 


Reply to: