$ ls BEYES.txt ./level2/beyes.txt
BEYES.txt./level2/beyes.txt
$ find -iname "beyes.txt"
./BEYES.txt
./level2/beyes.txt
# find /selinux/ -maxdepth 1 -name passwd
#无输出
# find / -maxdepth 3 -name passwd
/selinux/class/passwd嬀挀漀氀漀爀=#7030a0]#这里的 passwd 是个目录
/etc/passwd
/etc/pam.d/passwd
/usr/bin/passwd
... ...
$ find -iname "beyes.txt" -exec md5sum {} \;
d41d8cd98f00b204e9800998ecf8427e./BEYES.txt
d41d8cd98f00b204e9800998ecf8427e./level2/beyes.txt
$ find -iname "beyes.txt" -exec mv {} {}.bak \;$ find -iname "beyes.txt.bak"
./BEYES.txt.bak
./level2/beyes.txt.bak
[beyes@beyes find]$ ls
BEYES.txt.bak氀攀瘀攀氀2琀攀洀瀀.txt琀洀瀀.txt
[beyes@beyes find]$ ls level2/
beyes.txt.bak
$ find -not -iname "beyes.txt.bak"
.
./temp.txt
./level2
./tmp.txt
$ touch "tmp.txt"
$ touch "tmp.txt "
$ ls tmp*
tmp.txt琀洀瀀.txt
$ ls -i1 tmp*
132546 tmp.txt
132561 tmp.txt
[beyes@beyes find]$ find -inum 132561 -exec mv {} new_tmp.txt \;
[beyes@beyes find]$ ls *.txt
new_tmp.txt琀洀瀀.txt
$ ls -l
total 0
-rwxrwxrwx. 1 beyes beyes 0 Feb 26 01:42 all_perm.txt
-rw-r--r--. 1 beyes beyes 0 Feb 26 01:43 temp1.txt
-rwxr-xr-x. 1 beyes beyes 0 Feb 26 01:44 temp2.txt
-rw-------. 1 beyes beyes 0 Feb 26 01:44 temp3.txt
-----w----. 1 beyes beyes 0 Feb 26 01:45 temp4.txt
$ find . -perm -g=w -type f -exec ls -l {} \;
-rwxrwxrwx. 1 beyes beyes 0 Feb 26 01:42 ./all_perm.txt
-----w----. 1 beyes beyes 0 Feb 26 01:45 ./temp4.txt[/qutoe]
查找所有权限中只有用户组写权限的文件:
[quote]$ find . -perm g=w -type f -exec ls -l {} \;
-----w----. 1 beyes beyes 0 Feb 26 01:45 ./temp4.txt
$ find . -perm 600 -type f -exec ls -l {} \;
-rw-------. 1 beyes beyes 0 Feb 26 01:44 ./temp3.txt
$ find ~ -empty
/home/beyes/Downloads
/home/beyes/.mozilla/plugins
/home/beyes/.mozilla/extensions
/home/beyes/Templates
/home/beyes/Documents
/home/beyes/temp/find/temp1.txt[/qutoe]
找出当前目录下非隐藏的空文件(查找目录最大为 1 层):
[quote]$ find . -maxdepth 1 -empty -not -name ".*"
./Downloads
./Templates
./Documents
./Videos
./Pictures
./Public
./Desktop
./Music
$ find . -type f -exec ls -s {} \; |sort -n -r |head -5
340 ./os/linux/sta_ioctl.o
316 ./common/mlme.o
296 ./common/cmm_info.o
292 ./common/cmm_wpa.o
268 ./os/linux/rt_linux.o
$ find . -type f -exec ls -s {} \; |sort -n |head -5
4 ./common/eeprom.c
4 ./include/action.h
4 ./include/ags.h
4 ./include/br_ftph.h
4 ./include/chip/rt2870.h
$ find . -type f
$ find . -type d
$ find . -type s
$ find . -type f -name ".*"
$ find . -type d -name ".*"
$ find ~ -size +10M
/home/beyes/kernel-2.6.38.6-26.rc1.fc15.i686.rpm
/home/beyes/kernel-2.6.38.6-26.rc1.fc15.src.rpm
/home/beyes/rpmbuild/SOURCES/linux-2.6.38.tar.bz2
$ find ~ size -10M
$ find ~ size 10M
$ ls -lrt
total 40
drwxr-xr-x. 2 beyes beyes 4096 Dec 26 08:48 bolog
drwxr-xr-x. 2 beyes beyes 4096 Dec 30 23:48 3366
drwxr-xr-x. 2 beyes beyes 4096 Jan3 23:12 mywork
drwxr-xr-x. 2 beyes beyes 4096 Jan5 10:37 mytest
drwxr-xr-x. 2 beyes beyes 4096 Jan5 23:11 tianya
drwxr-xr-x. 4 beyes beyes 4096 Jan7 12:57 39net
drwxr-xr-x. 2 beyes beyes 4096 Jan8 22:44 moko
drwxr-xr-x. 3 beyes beyes 4096 Feb 23 23:10 meinv
drwxr-xr-x. 2 beyes beyes 4096 Feb 24 13:37 moko_qunet
drwxrwxr-x. 2 beyes beyes 4096 Feb 27 10:43 netease[/qutoe]
现在假设要查找修改时间比 Feb 23 23:10 要新的目录:
[quote]$ find -type d -newer meinv
.
./moko_qunet
./netease
$ touch TEMP.TXT
$ ls TEMP.TXT
TEMP.TXT
$ alias deltmp="find . -iname TEMP.TXT -exec rm {} \;"
$ deltmp
$ ls TEMP.TXT
ls: cannot access TEMP.TXT: No such file or directory
$ find / -type f -name "*.tar.gz" -size +1G -exec rm -i {} \;
root@bt:~# find . -path "*sh"
./.kde/share/apps/ksplash
./.kde/share/apps/ksplash/Themes/bt5-Ksplash
./shell/tmp.sh
./.ssh
./temp.sh
./.wine/drive_c/MinGW/libexec/gcc/mingw32/3.4.5/install-tools/fixinc.sh
./.gem/ruby/1.9.2/doc/typhoeus-0.3.3/ri/Typhoeus/NormalizedHeaderHash
./.gem/ruby/1.9.2/doc/typhoeus-0.2.4/ri/Typhoeus/NormalizedHeaderHash
./tmp.sh
./delay.sh
./.local/share/Trash
./debug.sh
root@bt:~# find . -regex ".*\(\.sh\|\.txt\)$"
./.kde/share/apps/ksplash/Themes/bt5-Ksplash/1600x1200/description.txt
./shell/tmp.sh
./temp.sh
./.subversion/README.txt
./.wine/drive_c/MinGW/libexec/gcc/mingw32/3.4.5/install-tools/fixinc.sh
./.gem/ruby/1.9.2/gems/mime-types-1.16/History.txt
./.gem/ruby/1.9.2/gems/mime-types-1.16/README.txt
./.gem/ruby/1.9.2/gems/mime-types-1.17.2/Manifest.txt
./tmp.sh
./delay.sh
./debug.sh
./.mozilla/firefox/nq474mcm.default/urlclassifierkey3.txt
find . -type f -atime -7 -print
find . -type f -atime 7 -print
find . -type f -atime +7 -print
root@bt:~# find . -name "*.sh"
./shell/tmp.sh
./temp.sh
./.wine/drive_c/MinGW/libexec/gcc/mingw32/3.4.5/install-tools/fixinc.sh
./tmp.sh
./delay.sh
./debug.sh
root@bt:~# find . \( -name "shell" -prune \) -o \( -name "*.sh" -print \)
./temp.sh
./.wine/drive_c/MinGW/libexec/gcc/mingw32/3.4.5/install-tools/fixinc.sh
./tmp.sh
./delay.sh
./debug.sh
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |