grep -q 'pattern' file.txt

Category: Text Processing

grep -q 'pattern' file.txt

Quiet mode — exit 0 if found, 1 if not (no output)

Runs silently — prints nothing, but exits with code 0 if the pattern was found or 1 if not. Used in scripts to test if a pattern exists.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.