开辟者大年夜赛路演 | 12月16日,技巧立异,北京不见不散
难度:轻易
商定:
#
- 须要应用 root 权限来履行指天敕令,可以直接应用 root 用户来履行也可以应用sudo
敕令$
- 可以应用通俗用户来履行指天敕令
案例
非递归搜刮包含指定字符串的文件
膳绫擎案例中忽视了所有的子目次。所谓递归搜刮就是指同时搜刮所有的子目次。
第一个例子让我们来搜刮 /etc/
目次下所有包含 stretch
字符串的文件,但不去搜刮个中的子目次:
# grep -s stretch /etc/*
/etc/os-release:PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
/etc/os-release:VERSION="9 (stretch)"
grep
的 -s
选项会在发明不存在或者不克不及攫取的文件时隐蔽报错信息。结不雅显示除了文件名之外,还有包含请求字符串的行也被一发誓出了。
递归地搜刮包含指定字符串的文件
下面的敕令会在 /etc/
及其子目次中搜刮包含 stretch
字符串的文件:
# grep -R stretch /etc/*
/etc/apt/sources.list:# deb cdrom:[Debian GNU/Linux testing _Stretch_ - Official Snapshot amd64 NETINST Binary-1 20170109-05:56]/ stretch main
/etc/apt/sources.list:#deb cdrom:[Debian GNU/Linux testing _Stretch_ - Official Snapshot amd64 NETINST Binary-1 20170109-05:56]/ stretch main
/etc/apt/sources.list:deb http://ftp.au.debian.org/debian/ stretch main
/etc/apt/sources.list:deb-src http://ftp.au.debian.org/debian/ stretch main
/etc/apt/sources.list:deb http://security.debian.org/debian-security stretch/updates main
/etc/apt/sources.list:deb-src http://security.debian.org/debian-security stretch/updates main
/etc/dictionaries-common/words:backstretch
/etc/dictionaries-common/words:backstretch's
/etc/dictionaries-common/words:backstretches
/etc/dictionaries-common/words:homestretch
/etc/dictionaries-common/words:homestretch's
/etc/dictionaries-common/words:homestretches
/etc/dictionaries-common/words:outstretch
/etc/dictionaries-common/words:outstretched
/etc/dictionaries-common/words:outstretches
/etc/dictionaries-common/words:outstretching
/etc/dictionaries-common/words:stretch
/etc/dictionaries-common/words:stretch's
/etc/dictionaries-common/words:stretched
/etc/dictionaries-common/words:stretcher
/etc/dictionaries-common/words:stretcher's
/etc/dictionaries-common/words:stretchers
/etc/dictionaries-common/words:stretches
/etc/dictionaries-common/words:stretchier
/etc/dictionaries-common/words:stretchiest
/etc/dictionaries-common/words:stretching
推荐阅读
腾讯发现者揭秘:怎么应对TensorFlow的安全风险,修复有多难
开辟者大年夜赛路演 | 12月16日,技巧立异,北京不见不散 12 月 15 日,雷锋网报道,腾讯安然平台部预研团队发明谷歌人工智能进修体系 TensorFlow 存在自身安然风险,可被黑客应用带来安然>>>详细阅读
本文标题:如何在Linux shell中找出所有包含指定文本的文件
地址:http://www.17bianji.com/lsqh/39864.html
1/2 1