[beyes@localhost ~]$ find ./ -mtime 0 # 0 表示从现在到 24 小时前
./
./pass.txt
./.lesshst
./.bash_history
[beyes@localhost ~]$ find ./ -newer pass.txt
./
./.bash_history
[beyes@localhost ~]$ ls -l .bash_history
-rw------- 1 beyes beyes 15805 01-06 01:48 .bash_history
[beyes@localhost ~]$ ls -l pass.txt
-rwxr-xr-x 1 beyes beyes 161 01-06 01:21 pass.txt
find `pwd` -user beyes # 列出当前目录下属于 beyes 这个用户的所有文件;注意这里使用的 pwd 命令
find / -nouser #如果删除了某个用户,但这个用户之前建立的文件还没删除的话,就会为 nouser 属性
[root@localhost ~]# find /var -type s #查找 socket 文件
/var/lib/xend/relocation-socket
/var/lib/xend/xend-socket
......
[root@localhost ~]# find /var -type p #查找 fifo 类型文件
/var/gdm/.gdmfifo
/var/run/autofs.fifo-net
/var/run/autofs.fifo-misc
.....
[root@localhost ~]# find / -perm +7000
/usr/kerberos/bin/ksu
...
[root@localhost ~]# ls -l /usr/kerberos/bin/ksu
-rwsr-xr-x 1 root root 147731 10-06 01:00 /usr/kerberos/bin/ksu #---s--s--t 中只要满足含有 s 或 t 就 列出
又如:
find /bin /sbin -perm +6000 #------s--t 中只要满足含有 s 或 t 就 列出
[beyes@localhost ~]$ find ./ -name "[A-Z]*" -print #在当前目录找出以大写字母开头的文件
./Demo/Demo_1
./.adobe/Flash_Player
.....
All following arguments to find are taken to be arguments to the command until an argument consisting of ‘;’ is encountered.
The string ‘{}’is replaced by the current file name being processed everywhere it occurs in the arguments to the command, not just in arguments where it is alone, as in some versions of find.
译:所有在 find 命令后面的参数都被当作是 command 的参数,直到遇到一个由 ; 组成的参数(如 \\; )为止。
在每一个从参数到命令的转换中,字符串 '{}' 由当前正在被处理到的文件名所代替,而不仅仅是单独替换一个参数( {} ) 。
[root@localhost ~]# find /home/beyes/Func_Test/ -type f -exec ls -l {} \\;
-rw-rw-r-- 1 beyes beyes 113 12-21 20:06 /home/beyes/Func_Test/F/fgetc/fgetc.c
[root@localhost ~]# find . -name "*.log" -mtime +5 -ok rm {} \\; #删除 5 天前的 Log 文件
< rm ... ./mplayer/configure.log > ? #这里提示是否要删除
[root@localhost basic_test]# ll
总计 56
-rwxrwxr-x 1 beyes beyes 12 12-27 11:07 add_tst.txt
drwxr-xr-x 13 root root 4096 01-02 01:05 evince
-rw-rw-r-- 1 beyes beyes 29 12-27 12:33 lserr.txt
-rw-rw-r-- 1 beyes beyes 152 01-01 22:19 pass.txt
-rw-rw-r-- 1 beyes beyes 825 12-27 11:05 play_again2.c
-rw-rw-r-- 1 beyes beyes 467 12-27 11:05 play_again3.c
-rw-rw-r-- 1 beyes beyes 63 01-03 03:15 zhengze.txt
[root@localhost basic_test]# find ./ -perm -644 -print | xargs chmod g-w # 这些文件的所属组没有写权限
[root@localhost basic_test]# ll
总计 56
-rwxr-xr-x 1 beyes beyes 12 12-27 11:07 add_tst.txt
drwxr-xr-x 13 root root 4096 01-02 01:05 evince
-rw-r--r-- 1 beyes beyes 29 12-27 12:33 lserr.txt
-rw-r--r-- 1 beyes beyes 152 01-01 22:19 pass.txt
-rw-r--r-- 1 beyes beyes 825 12-27 11:05 play_again2.c
-rw-r--r-- 1 beyes beyes 467 12-27 11:05 play_again3.c
-rw-r--r-- 1 beyes beyes 63 01-03 03:15 zhengze.txt
[root@localhost shell]# find ./ -type f |xargs file
./case_select.sh: Bourne-Again shell script text executable
./whilefilm.sh: Bourne-Again shell script text executable
./dfuntil.sh: Bourne-Again shell script text executable
./file_exec.sh: Bourne-Again shell script text executable
./name.txt: ASCII text
./for_test.sh: Bourne-Again shell script text executable
./breakout.sh: Bourne-Again shell script text executable
./ifcp.sh: Bourne-Again shell script text executable
./salutation.sh: Bourne shell script text executable
./whilereadline.sh: Bourne-Again shell script text executable
./val_quote.sh: ASCII text
./readname.sh: a /usr/bash script text executable
./iftest.sh: Bourne-Again shell script text executable
./breakout2.sh: Bourne-Again shell script text executable
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |