在使用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区别相关推荐

  1. linux egrep和grep区别,Linux中的Grep,Egrep和Fgrep有什么区别?

    在Unix系统上的一个着名的搜索工具,可以用于搜索任何东西,无论是一个文件,或一行或多行的文件是grep实用程序.它在功能上非常庞大,这可以归因于它支持的大量选项:使用字符串模式或reg-ex模式或基 ...

  2. linux egrep和grep区别,linux中grep和fgrep有什么区别

    1.grep: 传统的 grep 程序, 在没有参数的情况下, 只输出符合 RE 字符串之句子. 常见参数如下: -v: 逆反模示, 只输出"不含" RE 字符串之句子. -r: ...

  3. zgrep 与 grep 区别

    zgrep ' 输入你要查找的东东'   /目录 /文件 .gz  或者.log (当日) grep ' 输入你要查找的东东'   /目录 /文件 .gz  或者.log (非当日的压缩文件)

  4. php m grep event,linux grep (linux查找关键字在php出现的次数)

    http://www.th7.cn/system/lin/201508/127681.shtml 查找CleverCode在当前目录以及子目录,所有的php出现大于0的次数. # find -type ...

  5. Linux 命令(一) findgrep文件查找命令

    Linux 命令(一) find&grep文件查找命令 查找命令:find & grep 区别:(1) find命令是根据文件的属性进行查找,如文件名,文件大小,所有者,所属组,是否为 ...

  6. 正则表达式解析_学习笔记

    时间:2017.11.20 作者:李强 参考:man,info,magedu讲义 声明:以下英文纯属个人翻译,英文B级,欢迎纠正,以下内容纯属个人理解,并没有对错,只是参考,盗版不纠,才能有限,希望不 ...

  7. Linux下传说中的三剑客

    大家好!我是木荣. 今天给大家聊一聊Linux中文本操作的三剑客:awk.grep.sed,因其功能强大.使用频繁,且是Linux下文本处理的得力利器,常被称之为文本三剑客.grep常用于查找,sed ...

  8. linux里grep和egrep,fgrep的区别

    例子: 1. : 格式: grep [option] pattern filename 注意: pattern如果是表达式或者超过两个单词的, 需要用引号引用. 可以是单引号也可双引号, 区别是单引号 ...

  9. grep与egrep的区别

    grep与egrep的区别: 在linux系统环境下,我们通常使用grep命令来过滤出需要的行而egrep确很少使用,他们的区别其实很简单,grep默认不支持正则表达式,egrep默认支持正则表达式, ...

最新文章

  1. Spring中使用缓存时你应该知道的知识
  2. 网络抖动多少ms算正常_子宫内膜厚度多少算正常?
  3. DL之pix2pix(cGAN)之AC:基于pix2pix(cGAN)模型实现对图像实现Auto Color自动上色技术
  4. php在函数内使用全局变量
  5. 在Perl程序中显示进度条之多姿多彩的自写代码
  6. java空值转datetime,解决Java (Spring boot) 读取数据库字段,datetime 格式为null,抛出异常 Zero date value prohibited...
  7. 数据结构--队列Queue--链式队列、顺序队列
  8. HTML5网页录音和上传到服务器,支持PC、Android,支持IOS微信
  9. (三) 初识XMAL
  10. 计算机考研百天,2021非全日制研究生备考即将进入百天倒计时的你还在坚持吗?...
  11. 【编译原理】实验二 词法分析程序
  12. 电脑复制,电脑复制粘贴,详细教您电脑不能复制粘贴怎么办
  13. 第12届蓝桥杯 我的第一个比赛
  14. Sensible, not sensitive; simply complicated; predictably irrational; kindly demanding; constructivel
  15. 战神引擎传奇开服教程开服版本 开服服务器推荐战神引擎开服
  16. 淘宝网触屏版 - 学习笔记(1 - 关于meta)
  17. 地铁出行线路规划项目需求分析与设计
  18. Android 屏幕常亮
  19. c语言樱花飘落代码_用Python画一棵漂亮的樱花树,给女友惊喜
  20. 铁道部新客票系统设计(三)

热门文章

  1. 年薪50万以上的人,一般都是什么学历?怎么才能做到年薪50W?
  2. FFmpeg - Android 视频播放器
  3. android alsa 命令,[zz]Android下使用alsa-utils调试ALSA驱动
  4. intersect的用法简介
  5. Java实现微信公众号扫描二维码未关注时跳转关注界面已关注跳转业务界面
  6. Category的底层分析
  7. 第一章 初识OpenHarmony
  8. REST API 最佳实践 – REST 端点设计示例
  9. 陆虞候道 瑞星杀毒软件升级包
  10. 景安重启服务器打不开网站,如何解决网站无法访问 Apache也无法启动?