I’m trying to create aliases for the following commands which recursively convert all file permissions in the current directory to 644, and another one which will convert all directories to 755.
alias fixpermissions='cd ~/public_html/wp-content/themes/presstheme; find . -type f -exec chmod 644 {} \; find . -type d -exec chmod 755 {} \; cd'
However, when I run this I get:
find: paths must precede expression
These find commands work fine in the shell by themselves. Is there something special you have to do in order to run commands as aliases?
Thank you!
You need extra semi-colons to separate the two find commands from their surroundings:
You could benefit from using a sub-shell; then you don’t need the final
cd(which takes you home, not back to where you came from):And, since I started using shells before there were aliases, I’d make this into a legible script in my bin directory:
and probably I’d parameterize it, too:
Then I could specify a different directory if I wanted to, but it would default to the ‘normal’ one.