gpt4 book ai didi

regex - grep -e "Pattern"--regexp=Pattern 有什么用?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:52:26 25 4
gpt4 key购买 nike

我知道我们什么时候使用

grep -e "hello" -e "helo" 

这将同时匹配 hellohelo,但我在手册页中看到了以下内容:

-e PATTERN, --regexp=PATTERN

regexp是什么意思?

最佳答案

这意味着您可以使用具有相同参数的 -e--regexp 来获得相同的行为。

所以下面是等价的:

grep -e "hello" -e "helo"
grep --regexp='helo' --regexp='hello'

请注意,通过转义 |,您可以获得与常规 grep 相同的行为:

grep "hello\|helo"

或直接使用-E(或--extended-regexp):

grep -E "hello|helo"

关于regex - grep -e "Pattern"--regexp=Pattern 有什么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27742868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com