Trying to perform a recursive chmod on all the .sh files in a directory to make them executable
Asked
Active
Viewed 7.0k times
2 Answers
62
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:
-type f: Normal files only (skip directories, symlinks, named pipes and sockets, and the special files found in /dev)-iname: Ignore case in the name"*.sh": Globbing, telling thefindcommand to search for files with ".sh" extension-exec chmod +x {}: This tells thefindcommand to carry out achmodcommand on each found file. Making each executable\;: Indicating end of command
Eliah Kagan
- 119,640
George Udosen
- 37,534