find和grep区别
在使用linux时,经常需要进行文件查找。其中查找的命令主要有find和grep。两个命令是有区的。
区别:(1)find命令是根据文件的属性进行查找,如文件名,文件大小,所有者,所属组,是否为空,访问时间,修改时间等。
(2)grep是根据文件的内容进行查找,会对文件的每一行按照给定的模式(patter)进行匹配查找。
使用方法:
grep --help
BusyBox v1.26.2 (2019-12-27 14:43:11 CST) multi-call binary.Usage: grep [-HhnlLoqvsriwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f FILE [FILE]...Search for PATTERN in FILEs (or stdin)-H Add 'filename:' prefix-h Do not add 'filename:' prefix-n Add 'line_no:' prefix-l Show only names of files that match-L Show only names of files that don't match-c Show only count of matching lines-o Show only the matching part of line-q Quiet. Return 0 if PATTERN is found, 1 otherwise-v Select non-matching lines-s Suppress open and read errors-r Recurse-i Ignore case-w Match whole words only-x Match whole lines only-F PATTERN is a literal (not regexp)-E PATTERN is an extended regexp-m N Match up to N times per file-A N Print N lines of trailing context-B N Print N lines of leading context-C N Same as '-A N -B N'-e PTRN Pattern to match-f FILE Read pattern from file
Usage: find [-HL] [PATH]... [OPTIONS] [ACTIONS]Search for files and perform actions on them.
First failed action stops processing of current file.
Defaults: PATH is current directory, action is '-print'-L,-follow Follow symlinks-H ...on command line only-xdev Don't descend directories on other filesystems-maxdepth N Descend at most N levels. -maxdepth 0 appliesactions to command line arguments only-mindepth N Don't act on first N levels-depth Act on directory *after* traversing itActions:( ACTIONS ) Group actions for -o / -a! ACT Invert ACT's success/failureACT1 [-a] ACT2 If ACT1 fails, stop, else do ACT2ACT1 -o ACT2 If ACT1 succeeds, stop, else do ACT2Note: -a has higher priority than -o-name PATTERN Match file name (w/o directory name) to PATTERN-iname PATTERN Case insensitive -name-path PATTERN Match path to PATTERN-ipath PATTERN Case insensitive -path-regex PATTERN Match path to regex PATTERN-type X File type is X (one of: f,d,l,b,c,...)-perm MASK At least one mask bit (+MASK), all bits (-MASK),or exactly MASK bits are set in file's mode-mtime DAYS mtime is greater than (+N), less than (-N),or exactly N days in the past-mmin MINS mtime is greater than (+N), less than (-N),or exactly N minutes in the past-newer FILE mtime is more recent than FILE's-inum N File has inode number N-user NAME/ID File is owned by given user-group NAME/ID File is owned by given group-size N[bck] File size is N (c:bytes,k:kbytes,b:512 bytes(def.))+/-N: file size is bigger/smaller than N-links N Number of links is greater than (+N), less than (-N),or exactly N-prune If current file is directory, don't descend into itIf none of the following actions is specified, -print is assumed-print Print file name-print0 Print file name, NUL terminated-exec CMD ARG ; Run CMD with all instances of {} replaced byfile name. Fails if CMD exits with nonzero-exec CMD ARG + Run CMD with {} replaced by list of file names-delete Delete current file/directory. Turns on -depth option
find和grep区别相关推荐
- linux egrep和grep区别,Linux中的Grep,Egrep和Fgrep有什么区别?
在Unix系统上的一个着名的搜索工具,可以用于搜索任何东西,无论是一个文件,或一行或多行的文件是grep实用程序.它在功能上非常庞大,这可以归因于它支持的大量选项:使用字符串模式或reg-ex模式或基 ...
- linux egrep和grep区别,linux中grep和fgrep有什么区别
1.grep: 传统的 grep 程序, 在没有参数的情况下, 只输出符合 RE 字符串之句子. 常见参数如下: -v: 逆反模示, 只输出"不含" RE 字符串之句子. -r: ...
- zgrep 与 grep 区别
zgrep ' 输入你要查找的东东' /目录 /文件 .gz 或者.log (当日) grep ' 输入你要查找的东东' /目录 /文件 .gz 或者.log (非当日的压缩文件)
- php m grep event,linux grep (linux查找关键字在php出现的次数)
http://www.th7.cn/system/lin/201508/127681.shtml 查找CleverCode在当前目录以及子目录,所有的php出现大于0的次数. # find -type ...
- Linux 命令(一) findgrep文件查找命令
Linux 命令(一) find&grep文件查找命令 查找命令:find & grep 区别:(1) find命令是根据文件的属性进行查找,如文件名,文件大小,所有者,所属组,是否为 ...
- 正则表达式解析_学习笔记
时间:2017.11.20 作者:李强 参考:man,info,magedu讲义 声明:以下英文纯属个人翻译,英文B级,欢迎纠正,以下内容纯属个人理解,并没有对错,只是参考,盗版不纠,才能有限,希望不 ...
- Linux下传说中的三剑客
大家好!我是木荣. 今天给大家聊一聊Linux中文本操作的三剑客:awk.grep.sed,因其功能强大.使用频繁,且是Linux下文本处理的得力利器,常被称之为文本三剑客.grep常用于查找,sed ...
- linux里grep和egrep,fgrep的区别
例子: 1. : 格式: grep [option] pattern filename 注意: pattern如果是表达式或者超过两个单词的, 需要用引号引用. 可以是单引号也可双引号, 区别是单引号 ...
- grep与egrep的区别
grep与egrep的区别: 在linux系统环境下,我们通常使用grep命令来过滤出需要的行而egrep确很少使用,他们的区别其实很简单,grep默认不支持正则表达式,egrep默认支持正则表达式, ...
最新文章
- Spring中使用缓存时你应该知道的知识
- 网络抖动多少ms算正常_子宫内膜厚度多少算正常?
- DL之pix2pix(cGAN)之AC:基于pix2pix(cGAN)模型实现对图像实现Auto Color自动上色技术
- php在函数内使用全局变量
- 在Perl程序中显示进度条之多姿多彩的自写代码
- java空值转datetime,解决Java (Spring boot) 读取数据库字段,datetime 格式为null,抛出异常 Zero date value prohibited...
- 数据结构--队列Queue--链式队列、顺序队列
- HTML5网页录音和上传到服务器,支持PC、Android,支持IOS微信
- (三) 初识XMAL
- 计算机考研百天,2021非全日制研究生备考即将进入百天倒计时的你还在坚持吗?...
- 【编译原理】实验二 词法分析程序
- 电脑复制,电脑复制粘贴,详细教您电脑不能复制粘贴怎么办
- 第12届蓝桥杯 我的第一个比赛
- Sensible, not sensitive; simply complicated; predictably irrational; kindly demanding; constructivel
- 战神引擎传奇开服教程开服版本 开服服务器推荐战神引擎开服
- 淘宝网触屏版 - 学习笔记(1 - 关于meta)
- 地铁出行线路规划项目需求分析与设计
- Android 屏幕常亮
- c语言樱花飘落代码_用Python画一棵漂亮的樱花树,给女友惊喜
- 铁道部新客票系统设计(三)