This morning I had to remove all .ttx files from a number of directories. The way I normally do it didn't work because there were spaces in the path (directories named "Batch 1", etc):
pabloa:~/Development$ for x in `find * -name *.ttx`; do echo $x; done | head
batch
1_Bilingua
TTX/Uncleaned/317.xml.ttx
batch
1_Bilingua
TTX/Uncleaned/670.xml.ttx
batch
1_Bilingua
TTX/Uncleaned/474.xml.ttx
batch
pabloa:~/Development$ for x in `find * -name *.ttx`; do rm $x; done
rm: cannot remove `batch': No such file or directory
rm: cannot remove `1_Bilingua': No such file or directory
rm: cannot remove `TTX/Uncleaned/317.xml.ttx': No such file or directory
rm: cannot remove `batch': No such file or directory
rm: cannot remove `1_Bilingua': No such file or directory
rm: cannot remove `TTX/Uncleaned/670.xml.ttx': No such file or directory
rm: cannot remove `batch': No such file or directory
rm: cannot remove `1_Bilingua': No such file or directory
rm: cannot remove `TTX/Uncleaned/474.xml.ttx': No such file or directory
rm: cannot remove `batch': No such file or directory
Actually the proper way of working with results found by "find" is to instruct "find" itself to execute a command:
pabloa:~/Development$ find . -name *.ttx -exec echo {} \;
./batch 2_Bilingual TTX/Uncleaned/4520.xml.ttx
./batch 2_Bilingual TTX/Uncleaned/4504.xml.ttx
./batch 2_Bilingual TTX/Uncleaned/4508.xml.ttx
./batch 2_Bilingual TTX/Uncleaned/4501.xml.ttx
./batch 2_Bilingual TTX/Uncleaned/4499.xml.ttx
./batch 2_Bilingual TTX/Uncleaned/4515.xml.ttx
./batch 2_Bilingual TTX/Uncleaned/4521.xml.ttx
./batch 2_Bilingual TTX/Uncleaned/4519.xml.ttx
Although the syntax is a bit awkward, it's worth getting used to it. Here "{}" gets replaced by the names of the files found. And the semicolon has to be escaped "to protect them from expansion by the shell" as it says in the man page.
Cheers.
P.