标签:
find命令与locate命令的区别:
-iname: 按照文件名来搜索(可以使用通配符);
通配符有:*: 匹配任意多个字符;
?: 匹配任意一个字符;
[]: 匹配任意一个中括号内的字符;
[^]: 匹配任意一个不在中括号内的字符;
-iname: 按照文件名来搜索,并忽略大小写(可以使用通配符);
-user: 按照文件所有者搜索;
-group: 按照文件所属组搜索;
-nouser: 搜索不属于这个用户的文件;
-nogroup: 搜索不属于这个用户组的文件;
-uid: 按照用户UID搜索;
-gid: 按照用户GID搜索;
-exec COMMAND \;: 对查找到的文件执行指定的命令,查找结果太多可能导致命令溢出;
1
|
[root@demo tmp] # find /tmp/ -perm -001 -type f -exec ls -l {} \; |
1
|
[root@demo tmp] # find /tmp/ -perm -003 -type f | xargs chmod o-wx |
1
2
3
4
5
6
7
8
9
|
[root@demo tmp] # ll -rw-rw-r-- 1 hadoop hadoop 0 Jul 26 16:38 hadoop.doc -rwxr-xr-- 1 root hadoop 0 Jul 29 21:50 hadoop.xls -rwxr-xr-x 1 openstack openstack 0 Jul 26 16:38 openstack.xlsx [root@demo tmp] # find /tmp/ -iname "*.xls" -exec mv {} {}x \; [root@demo tmp] # ll -rw-rw-r-- 1 hadoop hadoop 0 Jul 26 16:38 hadoop.doc -rwxr-xr-- 1 root hadoop 0 Jul 29 21:50 hadoop.xlsx -rwxr-xr-x 1 openstack openstack 0 Jul 26 16:38 openstack.xlsx |
1
|
[root@demo tmp] # find /tmp/ -user root -a -group hadoop -ls |
1
|
[root@demo tmp] # find /tmp/ -not -user root -not -user hadoop -not -user bin -ls |
1
|
[root@demo tmp] # find /var/log/ -mtime -7 -not -user root -not -user hadoop |
1
|
[root@demo ~] # find / \(-nouser -o -nogroup\) -atime -30 |
1
|
[root@demo ~] # find /var/log/ -size +1M -type f |
1
|
[root@demo ~] # find /etc/init.d/ -perm -222 |
1
|
[root@demo ~] # find /etc/init.d/ -perm +222 |
1
|
[root@demo ~] # find /etc/init.d/ -perm -113 |
标签:
原文地址:http://www.cnblogs.com/Saviorsyang/p/cfdd58b45ba932ec0aadc25cf1e27ff2.html