find命令高级用法

1. 目录和文件使用不同的权限

# 查找当前目录,所有文件类型为d[目录]的文件 执行命令 chmod 755
find .  -type d -exec chmod 755 {} \;   
# 查找当前目录,所有文件类型为f[文件]的文件 执行命令 chmod 644
find .  -type f -exec chmod 644 {} \;

2. 删除不显示字符文件名的文件

find . -inum [inode] -exec rm {} \;

例子:

[root@localhost ~]# ls -il
total 420
202645692 -rw-r--r--  1 root root   4096 Jan 10 19:41 ??
[root@localhost ~]# find . -inum 202645692
./??
[root@localhost ~]# find . -inum 202645692 -exec rm {} \;
[root@localhost ~]# find . -inum 202645692
[root@localhost ~]#

 

posted @ 2017-02-06 20:32  镜水洞天  阅读(479)  评论(0编辑  收藏  举报