I created 512 files, with names made from combinations of permisions
(r
, w
, x
).
I created them like this:
touch ./{r,-}{w,-}{x,-}{r,-}{w,-}{x,-}{r,-}{w,-}{x,-}
and I want the files to have same permisions as their name indicates,
for example, files r-x--xrwx
should have permissions r-x--xrwx
.
I tried to do it like this:
for i in *
do
u=${i:0:3};g=${i:3:3};o=${i:6:3}
chmod u=$u,g=$g,o=$o -- $i
done
Some of the files end up with the correct permissions, but, for others, permissions don't match the name. How can I fix this?