Mailinglist Archive: opensuse (1264 mails)

< Previous Next >
Re: [opensuse] Quick question: how to call a script function from "find"?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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 '{}'
" \;


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 '{}' \;

Have fun,
Berny

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBAgAGBQJZP45QAAoJEEZQLveWkXGV6BcH/3a3acTjze3l0iDdCHmL5Xz2
ElneKZQyzcePdx9RJaEsr8YbuY3sVT5q85c5VKsbZ0KhGYeiAeLvhW2/AFRxdALR
4e5N3f8McOJJJn+BrMqwhoIWaZ6q7gfZfNQFsgybTWRz0l5QfEosAJNgACkPbVX2
Y8AoR7OioM6wVzSAikqwVPcKcT4H52EL9uxEcTGYLQC64Tain5xBFzUss1VP46zW
cup2iQCwrLXTva2++S5ouWm1CYDSSQwfPaXQoCL4jBtKCWwdWU6tLcVP0aeggQYY
3TRRX2rVNM3NMyI0i6rl7fii4ebnV8KKotKbXQBXIyBx0aGWC5DcSooNQiWkylE=
=bLR6
-----END PGP SIGNATURE-----

--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups