加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash – 打印匹配后的所有内容

发布时间:2020-12-15 18:53:16 所属栏目:安全 来源:网络整理
导读:参见英文答案 bash get string after character 5个 我有一个大文本文件,中间包含一个唯一的字符串.我想做的是使用grep打印字符串后的所有内容. cat textfile | grep "target_string"This highlights target_string but prints the whole filecat textfile |
参见英文答案 > bash get string after character 5个
我有一个大文本文件,中间包含一个唯一的字符串.我想做的是使用grep打印字符串后的所有内容.
cat textfile | grep "target_string"
This highlights target_string but prints the whole file

cat textfile | grep -o "target_string"
This prints only target_string

cat textfile | grep -o "target_string*"
This prints only target_string

如何在target_string之后打印所有内容?

你忘了’.’:
cat textfile | grep -o "target_string.*"

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读