如何通过grep文件找到< version> 1.1.9-beta< / version>的行? [英] How to grep file to find lines like <version>1.1.9-beta</version>?

查看:123
本文介绍了如何通过grep文件找到< version> 1.1.9-beta< / version>的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找建议< cat file | grep REGEX 来获取包含< version>任何东西< / version> 的行

Looking for suggestion to cat file | grep REGEX to get the lines with <version>anything</version>.

推荐答案

grep -F '<version>1.1.9-beta</version>' file




  • -F 会将您的模式匹配为文本文本

  • 如果您确实是指 cat

  • >任何:try grep'< version>。*< / version>'file grep -P' < version>。*?< / version>'file ,但使用正则表达式搜索xml是个坏主意。

    • -F will match your pattern as literal text
    • you don't need that useless cat
    • if you really mean anything: try grep '<version>.*</version>' file or grep -P '<version>.*?</version>' file , however searching xml with regex is bad idea.
    • 这篇关于如何通过grep文件找到&lt; version&gt; 1.1.9-beta&lt; / version&gt;的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆