[oclug] find help

Joe Burpee jeb at burkby.com
Mon Jan 21 09:02:00 EST 2008


On Sun, Jan 20, 2008 at 14:23:05 -0500, James Lockie wrote:
> I want to make all files 0 bytes.
> I tried this:
> find . -name \* -type f -exec "echo > {}" \;
 
You don't need "echo", but if you use it you will need "-n" to get
0-byte files.  Also for shell redirection ">" you need a shell:

find -type f -exec bash -c '> $0' {} \;

Maybe a less obscure way would be:

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

Anyway you might want to do a "pwd" to check where you are before
hammering a whole tree like this.

Joe



More information about the OCLUG mailing list