I have the following command
find . -type f -print0 | xargs -0 chmod 644
which would successfully change to 644 the permissions on all files in ., provided that the filenames contained no embedded spaces. However it doesn't work in general.
For example
touch "hullo world"
chmod 777 "hullo*"
find . -type f -print0 | xargs -0 chmod 644
returns
/bin/chmod: cannot access `./hello': No such file or directory
/bin/chmod: cannot access `world': No such file or directory
Is there a way to modify the command so that it can deal with files with embedded spaces?
Thanks very much for any advice.
Without
xargs
or with
xargs
the used
xargs
switches-0
If there are blank spaces or characters (including newlines) many commands will not work. This option take cares of file names with blank space.-I
Replace occurrences of replace-str in the initial-arguments with names read from standard input. Also, unquoted blanks do not terminate input items; instead the separator is the newline character.Explanation taken from here