8

Trying to perform a recursive chmod on all the .sh files in a directory to make them executable

  • Look into find and maybe xargs. – fkraiem Mar 4 '17 at 2:37
11

To make this possible you can use the find command and search for all files with a .sh extension and then run the chmod command on each one found:

find /directory/of/interest/ -type f -iname "*.sh" -exec chmod +x {} \;

Information:

  1. -type: File type to look for, here "file"
  2. -iname: Ignore case in the name
  3. "*.sh": Globbing, telling the find command to search for files with ".sh" extension
  4. -exec chmod +x {}: This tells the find command to carry out a chmod command on each found file. Making each executable
  5. \;: Indicating end of command

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.