0
点赞
收藏
分享

微信扫一扫

sed提取模式内容

小磊z 2023-06-15 阅读 45


提取模式开始和结束之间的部分:

sed 's/.*BEGIN_TEXT\(.*\)END_TEXT.*/\1/g' log.txt | sort  | uniq

例如提取下面的数字2:

tom says: I have 2 books on the table
 lily says: I have 3 books on the table

sed 's/.*I have \(.*\) books on.*/\1/g' log.txt

输出:

2
3

参考:
http://coolshell.cn/articles/9070.html
http://coolshell.cn/articles/9104.html



举报

相关推荐

0 条评论