Try KDE <[EMAIL PROTECTED]> writes: > I'm trying to run the following script: > for f in $(find . -name "*.txt"); do cmd1;cmd2;cmd3; done > ,where cmd1, cmd2 and cmd3 are arbiturary commands. The problem is, if > the found file names contain a space , for example "part1 part2.txt" > will be interpreted as "part1" and "part2.txt". I'm thinkin an esacping > tool may be able turn it into "part1\ part2.txt" before passing it to > "for" loop. Any thought?
Put your commands in a script, use find's "-print0" option to serve up the results seperated by '\0' characters (rather than whitespace), pipe these results to xargs to have your script applied to each result, and use xargs's "-0" option to have it read its arguments separated by '\0' (rather than whitespace): find . -name "*.txt" -print0 | xargs -r0 wc will apply 'wc' to every text file find finds, and whitespace in the filename is no problem. -- Leo Breebaart <[EMAIL PROTECTED]> -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]