[NTLUG:Discuss] How do I make all files in a directory of zero length?

George E. Lass George.Lass at osc.com
Wed Jun 6 13:31:12 CDT 2001


Is this pretty enough?

find .  -maxdepth 1 -type f  -exec cp /dev/null {} \;


The -maxdepth 0 prevents you from traversing subdirectories
the -type f prevents you from screwing up subdirectories and device
nodes
they can be eliminated to make it even prettier.

george


Lance Simmons wrote:
> 
> On Wed, Jun 06, 2001 at 12:43:20PM -0500, Fred James wrote:
> >
> > How do you define "pretty"?
> 
> I think I meant "short".
> 
>  cat /dev/null > *
> 
> could be rewritten as
> 
>  > *
> 
> That's short, but doesn't work.
> 
> The best solution so far is:
> 
>  for i in *; do > $i; done
> 
> Is there a shorter solution?
> 
> --
>   .~.
>   /v\   Lance Simmons
>  // \\  lance at lsimmons.net
> /(   )\
> __^_^________________________________________________________________________
> The problem with graduate students, in general, is that they have
> to sleep every few days.
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss



More information about the Discuss mailing list