find命令下排除部分目录修改权限

#!/bin/bash
# 项目文件夹、文件权限修改
# 批量修改文件夹或者文件的权限时,需要先忽略掉可写文件夹('./bootstrap/cache''./public/attachments''./public/images''./storage')

# 忽略 './bootstrap/cache' './public/attachments' './public/images' './storage' 文件夹及子文件
ignore_path="-not -path './bootstrap/cache' -and -not -path './bootstrap/cache/*' -and -not -path './public/attachments' -and -not -path './public/attachments/*' -and -not -path './public/images' -and -not -path './public/images/*' -and -not -path './storage' -and -not -path './storage/*'"
find_dirs="find . -type d $ignore_path"
find_files="find . -type f $ignore_path"
# 修改文件夹权限为 555
chmod_dirs="sudo $find_dirs -exec chmod 555 {} \;"
# 修改文件权限为 444
chmod_files="sudo $find_files -exec chmod 444 {} \;"


#echo $chmod_dirs
#echo $chmod_files
eval $chmod_dirs; eval $chmod_files

 

转载于:https://www.cnblogs.com/mikeluwen/p/8706893.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值