I have a fair amount of files in multiple directoroes that need to have an attribute modified, so a script is in order. Initially it seemed like creating a script with a find and then pipe it to xargs chmod would do the trick. Enter into the equation non-printable filenames... ugh... Has anyone in the forum dealt with this with any luck?
Thanks
You can deal with weird characters by assigning the filename to a variable, when you reference the variable, surround it in quotes. This works almost all of the time.
find ./someplace -name 'somefiles*' |\
while read filename
do
chmod +x "$file"
done
This may also work on your system:
find ./someplace -name 'somefiles*' -exec chmod +x "{}"
Thanks for the response, however, I still have the issue to deal with and perhaps I didn't explain the problem enough...
The script I originally came up with is:
find . \( -perm -0002 -a -type f \) | xargs chmod o-w
The 95% rule works here and the 5% fall through is what I'm looking to cover. The files with unprintable characters in the names passed to the chmod results in an unable to access message. I'm guessing that the last chacter in the filename value may be a null character? I'm guessing this simply because when I chmod against the individual file appended with a '*" I'm successful...