How to recursively set directory permissions with a find that lacks -exec?
6
votes
3
answers
1938
views
My Qnap NAS is cursed with a
find
command that lacks the -exec
parameter, so I have to pipe to something. The shell is: GNU bash, version 3.2.57(2)-release-(arm-unknown-linux-gnueabihf)
I'm trying to set the setgid bit on all subdirectories (not files) of the current directory.
This does not work:
find . -type d | xargs chmod g+s $1
Using "$1"
, "$(1)"
, $("1")
etc. will not work either. They all indicate that chmod
is getting passed a directory name containing spaces as two or more parameters (it spits out its standard help message about what parameters are supported).
I don't care to use xargs
if I don't have to; I think it chokes on long names anyway, doesn't it?
These and variants of them do not work:
find . -type d | chmod g+s
find . -type d | chmod g+s "$1"
I've thought of using awk
or sed
to inject quotation marks but I have to think there's an easier way to do this. What did people do before -exec
? (The sad thing is that I probably knew, back in 1995 or so, but have long since forgotten.)
PS: Various of these directory names will contain Unicode characters, the ?
symbol, etc. They're originally from macOS which is rather permissive. That said, I should probably replace all the ?
instances with something like the Unicode character ⁇
so Windows doesn't choke on them. But that's also going to require a similar find
operation with this crippleware version of find
.
Asked by S. McCandlish
(163 rep)
May 23, 2021, 08:50 AM
Last activity: May 24, 2021, 12:38 PM
Last activity: May 24, 2021, 12:38 PM