In <[🔎] 3f8297b21001070208q640b8abdudc0bda752f8877e1@mail.gmail.com>, Foss User
wrote:
>This is my directory structure:
>.
>| a.sh
>| a.txt
>+---foo bar
>| b.txt
>+---santa
>| | c.txt
>| \---humpty dumpty
>| e.txt
>\---test
> d.txt
>
>I want to do some operation on each file ending with .txt.
>
>Script:
>
>for file in `find -name "*.txt"`
Backticks aren't magic. They don't understand the output of the command
within, they simply break on whitespace.[1]
>do
> echo file: $file
>done
Try this:
find -name "*.txt" -exec /bin/sh -c 'echo file: $1' ignored {} \;
If using GNU find, you can use fewer processes by using a '+' instead of a ':'
and having the shell script (the part in single quotes) handle multiple
arguments.
[1] It's actually a bit more complex than that. Look for documentation on
word-splitting for your favorite shell.
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss@iguanasuicide.net ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/ \_/
Attachment:
signature.asc
Description: This is a digitally signed message part.