Linux下find使用方法介绍
2007-10-31 23:58
701 查看
1. Find 查找文件内容
比如:查找 test.c文件
Find / -name test.c –
find /tmp -name core -type f -print0 | xargs -0 /bin/rm –f
find . -name '*.c' -type f -print0 |xargs -0 grep -n 'printf'
在当前目录下查找.c的文件,并在所有查找出来的文件中查找printf这个单词,并将行号输出
-print0
True; print the full file name on the standard output, followed by a null character (instead of the newline character that ‘-print’ uses). This allows file names that contain newlines or other types of white space to be correctly interpreted by programs that processthe find output. This option corresponds to the ‘-0’ option ofxargs.
-print
True; print the full file name on the standard output, followed bya newline. If you are piping the output of find into another pro-gram and there is the faintest possibility that the files which youare searching for might contain a newline, then you should seri-ously consider using the ‘-print0’ option instead of ‘-print’. Seethe UNUSUAL FILENAMES section for information about how unusual characters in filenames are handled.
-type Supported. POSIX specifies ‘b’, ‘c’, ‘d’, ‘l’, ‘p’, ‘f’ and ‘s’. GNU find also supports ‘D’, representing a Door, where the OS pro-vides these.
xargs - build and execute command lines from standard input
--null, -0
Input items are terminated by a null character instead of by
whitespace, and the quotes and backslash are not special (every
character is taken literally). Disables the end of file string,
which is treated like any other argument. Useful when input items
might contain white space, quote marks, or backslashes. The GNU
find -print0 option produces input suitable for this mode.
比如:查找 test.c文件
Find / -name test.c –
find /tmp -name core -type f -print0 | xargs -0 /bin/rm –f
find . -name '*.c' -type f -print0 |xargs -0 grep -n 'printf'
在当前目录下查找.c的文件,并在所有查找出来的文件中查找printf这个单词,并将行号输出
-print0
True; print the full file name on the standard output, followed by a null character (instead of the newline character that ‘-print’ uses). This allows file names that contain newlines or other types of white space to be correctly interpreted by programs that processthe find output. This option corresponds to the ‘-0’ option ofxargs.
True; print the full file name on the standard output, followed bya newline. If you are piping the output of find into another pro-gram and there is the faintest possibility that the files which youare searching for might contain a newline, then you should seri-ously consider using the ‘-print0’ option instead of ‘-print’. Seethe UNUSUAL FILENAMES section for information about how unusual characters in filenames are handled.
-type Supported. POSIX specifies ‘b’, ‘c’, ‘d’, ‘l’, ‘p’, ‘f’ and ‘s’. GNU find also supports ‘D’, representing a Door, where the OS pro-vides these.
xargs - build and execute command lines from standard input
--null, -0
Input items are terminated by a null character instead of by
whitespace, and the quotes and backslash are not special (every
character is taken literally). Disables the end of file string,
which is treated like any other argument. Useful when input items
might contain white space, quote marks, or backslashes. The GNU
find -print0 option produces input suitable for this mode.
相关文章推荐
- 15条 linux Find 命令实际使用方法
- linux 下 find 命令的使用方法
- Linux中find命令使用介绍
- Linux编辑器vi使用方法详细介绍
- 15条 linux Find 命令实际使用方法
- linux svn客户端使用方法介绍
- Windows和Linux下使用Python访问SqlServer的方法介绍
- linux内存使用方法详细介绍
- Linux编辑器vi使用方法详细介绍
- linux常用命令-find和grep区别及使用方法
- [Linux] 内核的 /proc 文件系统介绍及使用方法
- 在使用selenium webdriver进行元素定位时,通常使用findElement或findElements方法结合By类返回的元素句柄来定位元素。其中By类的常用定位方式共八种,现分别介绍如下
- Linux下使用find查找文件内容,跳过所有目录名成和指定子目录的方法
- linux 环境下 Access,Modify,Change区别以及find指令简易使用方法
- linux 启动项管理,运行级别介绍、chkconfig管理工具使用方法、linux系统启动项说明
- Linux编辑器vi使用方法详细介绍
- Linux fuser工具使用方法介绍
- Linux:Ldd命令介绍及使用方法
- Linux命令find -perm使用方法
- Linux:Ldd命令介绍及使用方法