Linux find
find
find /etc -name sysconfig //查找etc下sysconfig文件
find /home -name test //查找home下test文件
find /home iname test //查找home下test文件不区分大小写
find / -type d -name alice //查找/下类型为目录名称为alice
find -type f -name 1.txt //查找当前目录下文件名为1.txt
find -type f -name "*.php" //查找当前目录下文件名后缀以php结尾
find -type f -perm 0777 -print //查找当前目录下权限为777的文件
find -type f -perm 755 -print //查找当前目录下权限为755的文件
find -type f ! -perm 777 -print //查找当前目录下权限不为777的文件
find -type f -perm 644 -print -exec chmod 777 {} \; //查找权限为644的文件并更改权限为777
find -type f -perm 777 -print -exec chmod 644 {} \; //查找权限为777的文件并更改权限为644
find -perm /u=r //查找属主有读的权限
find -perm /o=x //查找其他人有执行的权限
find -type f -name "*.txt" -exec rm -f {} \; //查找文件后缀以.txt的文件并删除
find -type f -name "*.php" -exec rm -f {} \; //查找文件后缀以.php的文件并删除
find -type f -name "1.txt" -exec rm -f {} \; //查找并删除名为1.txt的文件
find -type f -empty //查找当前目录下为空的文件
find / -type d -empty //查找/下的空目录
find -type f -name ".*" //查找当前目录下隐藏文件
find / -user root -name "1.txt" //查找/下属主为root名为1.txt的文件
find ~ -user root //当前目录下属主为root的文件
find ~/test -group alice //查找属组为alice的文件
find ~/test/ -group alice -iname "*.txt" //查找~/test/下属组为alice后缀为.txt的所有文件
find /var/log/nginx/ -cmin -60 //查找最近一小时内更改的文件
find -mmin -60 //查找最近一小时内修改的文件
find -amin -60 //查早最近一小时内访问的文件
find / -size 5M //查找所有5M的文件
dd if=/dev/zero of=test50M bs=1M count=50 //创建文件大小为50M
find / -size 50M //查找大小为50M的文件
find / -size +50M -size -100M //查找大于50M小于100M的文件
find -size 100M -exec rm -f {} \; //查找100M的文件并删除
find -type f -name "*.mp3" -size +10M -exec rm -f {} \; //删除文件名后缀为.mp3且大于10M的文件
浙公网安备 33010602011771号