![egrep 和 grep 有什么区别 - 简单的高级解释](https://linux22.com/image/194191/egrep%20%E5%92%8C%20grep%20%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%20-%20%E7%AE%80%E5%8D%95%E7%9A%84%E9%AB%98%E7%BA%A7%E8%A7%A3%E9%87%8A.png)
egrep
和 和有什么区别grep
?
我在网上搜索了一段时间,找不到任何简洁的内容。
除了具有一些扩展的正则表达式功能之外,它们是否相同egrep
?谢谢
答案1
在我的 RHEL 8 系统上:
$ ls -la /usr/bin/egrep
-rwxr-xr-x. 1 root root 28 Aug 12 2018 /usr/bin/egrep
$ file /usr/bin/egrep
/usr/bin/egrep: POSIX shell script, ASCII text executable
$ cat /usr/bin/egrep
#!/bin/sh
exec grep -E "$@"
所以,是的 -egrep
只是一个grep
打开扩展正则表达式功能的包装器。
答案2
摘自 Debian Gnu/Linux 手册页
... the variant programs egrep, fgrep and rgrep are the same
as grep -E, grep -F, and grep -r, respectively. These variants are
deprecated, but are provided for backward compatibility.