When I plug-in an USB stick (FAT) into my Mac or Ubuntu machine, all files have the executable bits set. After having copied the directory structure to my hard disk how do I remove the executable bits recursively just from the files and keep those on the directories?
How to remove executable bit recursively from files (not directories)
chmod(on Ubuntu) single command variant (starting in the current directory):
-R- operate recursively
-x- remove executable flags for all users
+X- set executable flags for all users if it is a directory
In this case the capital
Xapplies only to directories because all executable flags were cleared by
+Xsets executable flag(s) also if the flag was originally set for any of user, group or others.
chmod(which is present on Mac OS X) you have to do it separately in two commands:
(If you want to include hidden files in the main directory as well, you likely need to change * to . (point), but it is untested.)