linux - Bash: How to save 'find' options into a variable -


i need chown , chmod directories , files. not duplicate find filters, need save them variable.

the following code produces syntax error: "(" unexpected

findopts=( \( -path ./.git -o -name .gitignore \) -prune -o )  find . "${findopts[@]}" chown www-data:www-data {} \+  find . "${findopts[@]}" -type d -exec chmod 550 {} \+ find . "${findopts[@]}" -type f -exec chmod 440 {} \+ 

since chmod calls enabling x bit on directories , disabling in files, can use x (capital x) in chmod (after clearing them first):

chmod a=,ug+rx file[..] 

also, can use multiple -exec in find (at least in gnu find), execute find once, without need save options:

find . [your filters here] \     -exec chown www-data:www-data {} \;  \     -exec chmod a=,ug+rx {} \; 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -