Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


find -exec | 12 comments | Create New Account
Click here to return to the 'find -exec' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
find -exec
Authored by: a1291762 on Mar 31, '05 05:15:23PM

> find . -name * -exec echo ""| cat > {} \;

The reason this fails is because | and > are interpreted by the shell, not by find. Also your {} isn't quoted so any spaces in the filenames are going to be mishandled. You can do the copy /dev/null thing or something like this:

find . -type f -exec sh -c ':> "{}"' \;

Find files and run a shell process which will execute :>"file". : is a null command and redirecting it's output to a file clears it. I use it because it shorter than other things lke echo "">file or cp /dev/null file.

Your -name * is evil. The shell will interpret that if it can which you probably don't want. It's not required anyway unless you do something like -name '*.mp3'



[ Reply to This | # ]