[NTLUG:Discuss] How do I make all files in a directory of zero length?
Lance Simmons
lance at lsimmons.net
Wed Jun 6 12:20:26 CDT 2001
On Wed, Jun 06, 2001 at 11:49:13AM -0500, George E. Lass wrote:
>
> #!/bin/bash
> for FILE in *
> do
> if [ -f $FILE -a $FILE != cmd ]
> then
> > $FILE
> fi
> done
>
>
> Then do: chmod 777 cmd
> ./cmd
for FILE in *; do > $FILE
also works.
I couldn't get the other suggestion
cat /dev/null > *
to work; bash complains about an ambiguous redirect.
I'm happy to go with the "for ... in *; do > $..." construction,
but I wonder if there's not a prettier way.
Thanks to everyone who replied.
--
.~.
/v\ Lance Simmons
// \\ lance at lsimmons.net
/( )\
__^_^________________________________________________________________________
Technology is the knack of so arranging the world that we do not experience it.
-- Max Frisch
More information about the Discuss
mailing list