---
title: egrep and fgrep are deprecated
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Static Code Analysis (SAST) > SAST
  Rules > egrep and fgrep are deprecated
---

# egrep and fgrep are deprecated

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ().
{% /alert %}

{% /callout %}

## Metadata{% #metadata %}

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

**Language:** Bash

**Severity:** Notice

**Category:** Code Style

## Description{% #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{% #non-compliant-code-examples %}

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

## Compliant Code Examples{% #compliant-code-examples %}

```bash
#!/bin/bash
grep -E 'pat' file.txt
grep -F 'literal' file.txt
grep foo bar.txt
/bin/grep -E pat f
```
  Seamless integrations. Try Datadog Code SecurityDatadog Code Security 
{% icon name="icon-external-link" /%}
 