For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/static_analysis/static_analysis_rules/bash-code-quality/deprecated-egrep-fgrep.md. A documentation index is available at /llms.txt.
This product is not supported for your selected Datadog site. ().

Metadata

ID: bash-code-quality/deprecated-egrep-fgrep

Language: Bash

Severity: Notice

Category: Code Style

Description

egrep and fgrep are legacy commands. They were deemed obsolescent by POSIX and removed from the standard. They are planned to be removed entirely in a future release.

Prefer grep -E for extended regular expressions and grep -F for fixed-string matching.

Non-Compliant Code Examples

#!/bin/bash
egrep 'pat' file.txt
fgrep needle haystack.txt
/usr/bin/egrep foo bar

Compliant Code Examples

#!/bin/bash
grep -E 'pat' file.txt
grep -F 'literal' file.txt
grep foo bar.txt
/bin/grep -E pat f
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Security