under cases directory, below are the sub directories and each directory has files.
/local/home/app/cases/1
/local/home/app/cases/2
/local/home/app/cases/3
/local/home/app/cases/4
File types are .txt .sh and so on. recursively, in each directory, I only like to change the .sh files permission to 744. can someone pls help me on this. thanks:)
Escaping the period is not really necessary, and if there is a lot of files, using xargs is more efficient -- it will run only one chmod call on many files. Using -0 will allow for filenames with white characters:
It is even more efficient to leave xargs out of the mix and let find invoke chmod with multiple operands by using + instead of \; to terminate the list of -exec arguments:
Note that the find -iname primary and the chmod -c option are extensions to the standards that are not supplied by all implementations of find and chmod . If your system doesn't have these features, as long as you don't have files that end with .sH , Sh , or .SH and don't care about seeing a status message for every file whose permissions were changed, the following command should work on any system that supports the basic requirements of the standards for chmod and find :
If you do have mixed case filename extensions and your system doesn't support -iname , let us know and we can help you modify the find to look for all four combinations of capitalization using multiple -name primaries.
Just out of curiosity, why do you want these files to have 744 rather than 755 permissions?
~/case$ chmod -c -R 744 {1..3}/*.txt
mode of `1/file.txt' changed from 0755 (rwxr-xr-x) to 0744 (rwxr--r--)
mode of `2/file.txt' changed from 0755 (rwxr-xr-x) to 0744 (rwxr--r--)
mode of `3/file.txt' changed from 0755 (rwxr-xr-x) to 0744 (rwxr--r--)