У меня есть этот сценарий, и я хотел бы его упростить. Любая помощь приветствуется:
#!/bin/ash
chmod 775 /path/to/directory
chown -R http:http /path/to/directory
cd /path/to/directory
find . -type d -exec chmod 775 {} \; ; find . -type f -exec chmod 664 {} \;
chmod 775 /path/to/directory1
chown -R http:http /path/to/directory1
cd /path/to/directory1
find . -type d -exec chmod 775 {} \; ; find . -type f -exec chmod 664 {} \;
chmod 775 /path/to/directory2
chown -R http:http /path/to/directory2
cd /path/to/directory2
find . -type d -exec chmod 775 {} \; ; find . -type f -exec chmod 664 {} \;
Спасибо.
#!/bin/ash
for i in \
'/path/to/directory' \
'/path/to/directory1' \
'/path/to/directory2' \
;do
chmod 775 "$i"
chown -R http:http "$i"
cd "$i" && \
find . \
-type d -exec chmod 775 {} \; \
-o \
-type f -exec chmod 664 {} \;
done
Поскольку вы выполняете тот же набор операций с dir1 / 2/3, имеет смысл переместить их в цикл.
Две команды поиска также можно переместить внутрь одной с помощью правил логической логики.