# grep Simulator

Simulate line filtering, context, counts, word matching, and matching-text output on pasted ASCII text without searching files.

## URL

https://ilham.dev/tools/grep-simulator/

## What It Does

Simulate grep on one pasted ASCII text sample. Choose fixed strings, basic regex, or extended regex, with case-insensitive matching, line numbers, whole-word matching, inverted selection, context, selected-line counts, and matching-text output. No file paths, directory traversal, or remote requests are involved.

## Features

- Simulate fixed-string, basic-regex, and extended-regex line searches
- Apply ignore case, word boundaries, inversion, context, counts, and matching-text output
- Use leftmost-longest whole matches within the documented subset
- Report selected-line counts and simulated grep exit status

## Input

ASCII sample, pattern, and search settings text input.

## Output

Simulated grep output and selected-line summary text output.

## Privacy

Processing happens locally in the browser.

No input data is uploaded to ilham.dev.

- Requires login: false
- Requires API key: false
- Stores user data: false


## Examples

- Is this a complete GNU grep implementation?
- Does count show matching occurrences or matching lines?
- Why is there no output with invert and matching text only?
- Is my text sent anywhere or stored?


## Limitations

- Bounded ASCII/C-locale subset, not the full GNU grep implementation
- No Perl regex, backreferences, shorthand escapes, Unicode, binary data, or recursive file searching
- Maximum 50,000 input characters, 256 pattern characters, context 50, and bounded work/output


## Related Tools

- https://ilham.dev/tools/sed-simulator/
- https://ilham.dev/tools/grep-pattern-builder/


## Questions

### Is this a complete GNU grep implementation?

No. It uses a bounded local regex engine for a documented ASCII/C-locale subset, with leftmost-longest whole-match selection. Perl regex, backreferences, GNU shorthand/word-boundary escapes, locale-specific matching, binary inputs, and file searching are not implemented.

### Does count show matching occurrences or matching lines?

It counts selected lines, like grep -c, not the number of individual matches. With invert enabled, it counts lines that do not match. Count takes precedence over matching-text output.

### Why is there no output with invert and matching text only?

With zero context, invert selects non-matching lines, so there are no matching substrings to print. The summary can still report selected lines and a simulated successful exit status. With context enabled, matching context rows may print match fragments instead.

### Is my text sent anywhere or stored?

The simulator processes the pasted sample in the browser without tool input storage or upload. Its output and source are separate. Copy output uses only the result, not the original sample.

