Linux下find使用方法介绍

 
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.
 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值