文章目录
-
-
-
-
- e.g.01 find /tmp -name core -type f -print | xargs /bin/rm -f
- e.g.02 find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
- e.g.03 find . -type f -exec file '{}' \;
- e.g.04 find / \( -perm -4000 -fprintf /root/suid.txt '%#m %u %p\n' \) , \( -size +100M -fprintf /root/big.txt '%-10s %p\n' \)
- e.g.05 find $HOME -mtime 0
- e.g.06 find /sbin /usr/sbin -executable \! -readable -print
- e.g.07 find . -perm 664
- e.g.08 find . -perm -664
- e.g.09 find . -perm /222
- e.g.10 find . -perm /220 find . -perm /u+w,g+w find . -perm /u=w,g=w
- e.g.11 find . -perm -220 find . -perm -g+w,u+w
- e.g.12 find . -perm -444 -perm /222 \! -perm /111 find . -perm -a+r -perm /a+w \! -perm /a+x
- e.g.13 cd /source-dir find . -name .snapshot -prune -o \( \! -name '*~' -print0 \) | cpio -pmd0 /dest-dir
- e.g.14 find repo/ \( -exec test -d '{}'/.svn \; -or -exec test -d {}/.git \; -or -exec test -d {}/CVS \; \) -print -prune
- e.g.15 find /tmp -type f,d,l
- 扩展e.g.13,使用find命令的时候如何忽略指定的文件夹
-
-
-
前言:本文的例子均来源于man手册第一章节的find,man 1 find查看
e.g.01 find /tmp -name core -type f -print | xargs /bin/rm -f
手册原文:
find /tmp -name core -type f -print | xargs /bin/rm -f
Find files named core in or below the directory /tmp and delete them. Note that this will work incorrectly if there are any filenames containing newlines, single or double quotes, or spaces.
效果:
删除/tmp
路径下面名字为core
的普通文件,但是文件不能够有换行符、单引号、双引号和空格符,否则会出错。