在同一命令中组合多个正则表达式 [英] Group more than one regular expression in the same command

查看:32
本文介绍了在同一命令中组合多个正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在一个命令中组合两个正则表达式

How to group two regular expression in one command

例如,如果有这样的文件:

example if have a file like:

age22
Helwan University Engineering Faculty
ITI-intake33
bye FOr NOW
i am mahmoud 34
mie 4
a

我想搜索以 by 开头并以 W 结尾的行 ???

And I want to search for the line that start with by and end with W ???

使用grep命令

推荐答案

为此,您不需要多个正则表达式.

You don't need more than one regular expression for this.

grep '^by.*W$' filename.txt

应该够了.

这篇关于在同一命令中组合多个正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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