for i in `find -type f` ; do chmod -x $i ; done
дасть купу помилок, якщо попадуться файли з пробілами. От як зробити щоб масив i мав члени:The letters ‘rwxXstugo’ select the new permissions for the affected users: read (r), write (w), execute (or access for directories) (x), execute only if the
file is a directory or already has execute permission for some user (X), set user or group ID on execution (s), sticky (t), the permissions granted to the
user who owns the file (u), the permissions granted to other users who are members of the file’s group (g), and the permissions granted to users that are in
neither of the two preceding categories (o).
eval "list=( $( find -P '.' \
-type f \
-printf '"%h/%f"\n' ) )"
# Тепер ми маємо всі ці файли у масиві й можемо звертатися до них як "${list[0]}" "${list[1]}" ... "${list[${#list[@]}-1]}" = "${list[@]}"
Наприклад:Конкретний приклад вирішується таким чином:Код: [Вибрати]for i in `find -type f` ; do chmod -x $i ; done
find -type f -exec chmod -x {} +
А як масив до циклу закинути?
for i in "${list[@]}" ; do
echo "${i}" # Лапки обов'язкові!
done
абоfor (( i=${#list[@]}; i--; )) ; do
echo "#${i}: ${list[${i}]}"
done
$ find -type f -exec chmod -x {} +
find: missing argument to `-exec'
$ find --version # ?
$ man find # /-exec і подивіться, чи є там варіант команди з плюсиком.
# коли ні - значить у вас дивна версія find, замініть + на \;
Як примусити find закоментовувати рядки лапками, щоб передати їх до іншої програми?
Наприклад:Код: [Вибрати]for i in `find -type f` ; do chmod -x $i ; done
find . -type f -exec chmod -x {} \;
$ find -type f -exec chmod -x {} +
find: missing argument to `-exec'
Можливі варіації на тему плюса в кінці - зазвичай find`ом користуюсь під FreeBSD, і там багацько параметрів відрізняються від лінуксових версій.На мому LFS та у Дебі працює.
GNU find version 4.2.28
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION
GNU find version 4.2.28
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION
А як масив до циклу закинути?
<u>_________________________________</u>
$ find -type f -exec chmod -x {} +
find: missing argument to `-exec'
$ find -type f -exec chmod -x \{\} \;