On 08/17/2011 06:52 PM, Randal L. Schwartz wrote:
> Jameson> I haven't been able to get this one yet.
> Jameson> Challenge: A one-line statement (pipes okay, but explicit loops not)
> Jameson> that empties all found files (as for debugging with /var/log,
> Jameson> perse).
> Randal> In a single directory?
> Randal>
> Randal> "rm *".
> Randal>
> Randal> What's hard with that?
Well, to meet the problem at hand in /var/log: various log utilities
expect the existence of files, or will complain. So, the best solution
I've come up with (using Sam Hart's truncate suggestion) is:
find . -type f -exec truncate -s 0 {} \;
rm * might otherwise work well in most settings, but probably doesn't
meet the spec of the original one-liner problem statement. :-)
- Jameson
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug