Using chmod
, I do chmod +x *.sh
in the current directory but what if I want to change all files including files within subfolders that has an sh file extension?.
chmod +x -R *
will work but I need something more like chmod +x -R *.sh
To change file and directory permissions, use the command chmod (change mode). The owner of a file can change the permissions for user ( u ), group ( g ), or others ( o ) by adding ( + ) or subtracting ( - ) the read, write, and execute permissions.
Permissions of 644 mean that the owner of the file has read and write access, while the group members and other users on the system only have read access. For executable files, the equivalent settings would be 700 and 755 which correspond to 600 and 644 except with execution permission.
To modify the permission flags on existing files and directories, use the chmod command ("change mode"). It can be used for individual files or it can be run recursively with the -R option to change permissions for all of the subdirectories and files within a directory.
use find:
find . -name "*.sh" -exec chmod +x {} \;
Try using the glorious combination of find with xargs.
find . -iname \*.sh -print0 | xargs -r0 chmod +x
The .
is the directory to start in, in this case the working directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With