Comments on: 6 Deprecated Linux Commands and Alternative Tools You Should Use https://www.tecmint.com/deprecated-linux-commands/ Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks. Mon, 11 Dec 2023 04:06:38 +0000 hourly 1 By: Ravi Saive https://www.tecmint.com/deprecated-linux-commands/comment-page-1/#comment-2113316 Mon, 11 Dec 2023 04:06:38 +0000 https://www.tecmint.com/?p=49264#comment-2113316 In reply to Ron Hunt.

@Ron,

I understand your concern about the difference in behavior between egrep and grep -E when matching strings with spaces in RHEL 7 and RHEL 9.3. You’re correct that the deprecated egrep command in RHEL 7 treats spaces as part of the pattern, while grep -E in RHEL 9.3 does not.

Here’s a breakdown of the situation:

In RHEL 7, the following command will match the string “text1 text2” because egrep considers spaces within the quoted pattern as part of the pattern itself.

egrep "text1 text2"

In RHEL 9.3, the following command is deprecated and might behave differently depending on the specific implementation.

egrep "text1 text2"

The following command uses the extended regular expressions mode but does not consider spaces inside the quoted pattern as part of the pattern. Therefore, it won’t match the string “text1 text2“.

grep -E "text1 text2"
]]>
By: Ron Hunt https://www.tecmint.com/deprecated-linux-commands/comment-page-1/#comment-2113287 Mon, 11 Dec 2023 02:45:58 +0000 https://www.tecmint.com/?p=49264#comment-2113287 I am involved with an upgrade from RHEL 7 to RHEL 9.3. We have many ksh scripts that use egrep. I have read the articles saying that “egrep” is deprecated and use “grep -E” instead. However I have done numerous tests under 9.3 and “grep -E” does not behave the same as “egrep” on RHEL 7.

On RHEL 7, for example: egrep “text1 text2” works -- the string including a space character is successfully matched. But with RHEL 9.3 I cannot get “egrep” or “grep -E” to match that string.

]]>