作家
登录

如何在Linux shell中找出所有包含指定文本的文件

作者: 来源: 2017-12-18 10:45:05 阅读 我要评论

  • /etc/dictionaries-common/words:stretchy
  • /etc/grub.d/00_header:background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"`
  • /etc/os-release:PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
  • /etc/os-release:VERSION="9 (stretch)"
  • 搜刮所有包含特定单词典文件

    膳绫擎 grep 敕令的案例中列出的是所有包含字符串 stretch 的文件。也就是说包含 stretchesstretched 等内容的行也会被显示。 应用 grep-w 选项会只显示包含特定单词典行:

    1. # grep -Rw stretch /etc/*
    2. /etc/apt/sources.list:# deb cdrom:[Debian GNU/Linux testing _Stretch_ - Official Snapshot amd64 NETINST Binary-1 20170109-05:56]/ stretch main
    3. /etc/apt/sources.list:#deb cdrom:[Debian GNU/Linux testing _Stretch_ - Official Snapshot amd64 NETINST Binary-1 20170109-05:56]/ stretch main
    4. /etc/apt/sources.list:deb http://ftp.au.debian.org/debian/ stretch main
    5. /etc/apt/sources.list:deb-src http://ftp.au.debian.org/debian/ stretch main
    6. /etc/apt/sources.list:deb http://security.debian.org/debian-security stretch/updates main
    7. /etc/apt/sources.list:deb-src http://security.debian.org/debian-security stretch/updates main
    8. /etc/dictionaries-common/words:stretch
    9. /etc/dictionaries-common/words:stretch's
    10. /etc/grub.d/00_header:background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"`
    11. /etc/os-release:PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
    12. /etc/os-release:VERSION="9 (stretch)"

    显示包含特定文本的文件名

    膳绫擎的敕令都邑产生多余的输出。下一?案例则会递归地搜刮 etc 目次中包含 stretch 的文件并只输出文件名:

    1. # grep -Rl stretch /etc/*
    2. /etc/apt/sources.list
    3. /etc/dictionaries-common/words
    4. /etc/grub.d/00_header
    5. /etc/os-release

    大年夜小写不敏感的搜刮

    经由过程应用 grep-i 选项,grep 敕令还会列出所有包含 StretchSTRETCHStReTcH 等内容的文件,也就是说进行的是大年夜小写不敏感的搜刮。

    1. # grep -Ril stretch /etc/*
    2. /etc/apt/sources.list
    3. /etc/dictionaries-common/default.hash
    4. /etc/dictionaries-common/words
    5. /etc/grub.d/00_header

        推荐阅读

        腾讯发现者揭秘:怎么应对TensorFlow的安全风险,修复有多难

      开辟者大年夜赛路演 | 12月16日,技巧立异,北京不见不散 12 月 15 日,雷锋网报道,腾讯安然平台部预研团队发明谷歌人工智能进修体系 TensorFlow 存在自身安然风险,可被黑客应用带来安然>>>详细阅读


      本文标题:如何在Linux shell中找出所有包含指定文本的文件

      地址:http://www.17bianji.com/lsqh/39864.html

    关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)