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

I'm not sure why you would want to chown to 'cer' and later to 'cer-g'.
This looks redundant to me.

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

He, he - what about script recursion? ;-)

#!/bin/bash

if [ "$1" = '__do_action__' ]; then

shift 1 \
&& sudo chown cer:cer "$@" \
&& chmod u+r+w+x,g+w+x,o+r-w-x,+t "$@" \
&& sudo chown cer-g:cer "$@"
exit $?

fi

find /home/cer/Fusion/Videos/ -type d -exec "$0" __do_action__ '{}' +

(The above is untested, as I don't have users 'cer', 'cer-g', etc.,
but it should work.)

Have a nice day,
Berny

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

iQEcBAEBAgAGBQJZP4tfAAoJEEZQLveWkXGVdR4H+gKBstuUyzB7cjBQY00yKX0z
akOUWzSXSdWI88SY+sYHqwkp90kCckfVVAuWxNUg4+s5S2mWJfU1eVH2gLX6KV4A
9UVCu4APUVoys/YgPEeoenhwPbHviQjlH+1kmpGlHvko8qQ4O82nrLgJLFCH//7y
kCm0nBFIF4Qmhp8u4dQSMliRwg9rJ4yoGPGI6RzvKsH9lqeLQ5LihWDPHWZjb3sK
rLjsJlot59+3sYl4R4uKdcAGl9I0sbvnUpayA9jCvSFh4Zp2gpQsftZXpRZ76WkS
HfOjpZVpMUy8KoBkybyROfTvKI3bbON1y7h5H8CSN4a5M449p2Wkb1xtr2ZB9o0=
=aFVu
-----END PGP SIGNATURE-----

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

< Previous Next >
Follow Ups