Mailinglist Archive: opensuse (1264 mails)

< Previous Next >
Re: [opensuse] Quick question: how to call a script function from "find"?
On 2017-06-13 09:03, Bernhard Voelker wrote:
On 06/13/2017 05:38 AM, Carlos E. R. wrote:
The intention was to convert:

find /home/cer/Fusion/Videos/ -type d -exec sudo chown cer:cer '{}' \; find
/home/cer/Fusion/Videos/ -type d -exec
chmod u+r+w+x,g+w+x,o+r-w-x,+t '{}' \; find /home/cer/Fusion/Videos/ -type d
-exec sudo chown cer-g:cer '{}' \;
#setfacl -m u:wwwrun:rx /data/waterhoard/Fusion.uno/Videos

to a single "find". And calling a function in the same script seemed to me
the clearest way of doing it.

Another way:
this only work if you stick to the single-argument "\;" (instead of "+"),
because then find(1) will replace every occurrence of '{}' in the
command to be executed:

find /home/cer/Fusion/Videos/ -type d -exec \
sh -c "
sudo chown cer:cer '{}' &&
chmod u+r+w+x,g+w+x,o+r-w-x,+t '{}' &&
sudo chown cer-g:cer '{}'
" \;

This seems nice. I suppose it doesn't mater that the directories found
have spaces?



Yet another way: use multiple -exec arguments to one find(1):

find /home/cer/Fusion/Videos/ -type d \
-exec sudo chown cer:cer '{}' \; \
-exec chmod u+r+w+x,g+w+x,o+r-w-x,+t '{}' \; \
-exec sudo chown cer-g:cer '{}' \;

I like this one best. :-)

--
Cheers / Saludos,

Carlos E. R.
(from 42.2 x86_64 "Malachite" at Telcontar)

< Previous Next >
Follow Ups