Files
bare-operating-system/packages/bare-os-coreutils/man/pages/grep.json
T
2026-04-03 22:34:08 -04:00

119 lines
2.8 KiB
JSON

{
"name": "grep",
"section": 1,
"title": "pattern matching utility",
"synopsis": [
"grep [-E|-F] [-i] [-v] [-w] [-n] [-c] [-l] [-q] [-s] [-H|-h] [-e pat] ... [-f file] ... [pattern] [file...]"
],
"description": "Searches input or files for lines matching a pattern. Uses JavaScript RegExp unless -F (fixed string). Not bit-identical to GNU grep.",
"options": [
{
"flag": "-E",
"meaning": "Extended regex (accepted; patterns use JS RegExp)"
},
{
"flag": "-F",
"meaning": "Fixed string match"
},
{
"flag": "-r, --recursive",
"meaning": "Recurse into directories (skips **`.git`**; max depth 64); with no file args, searches **`.`**"
},
{
"flag": "-i",
"meaning": "Ignore case"
},
{
"flag": "-v",
"meaning": "Invert match"
},
{
"flag": "-w",
"meaning": "Match whole words (regex: \\b…\\b; fixed: non-alphanumeric boundaries)"
},
{
"flag": "-n",
"meaning": "Prefix lines with line number"
},
{
"flag": "-c",
"meaning": "Count matching lines only"
},
{
"flag": "-l",
"meaning": "List files with matches"
},
{
"flag": "-q",
"meaning": "Quiet (exit status only)"
},
{
"flag": "-s",
"meaning": "Suppress error messages"
},
{
"flag": "-H / -h",
"meaning": "Force / suppress filename prefix"
},
{
"flag": "-e pat",
"meaning": "Specify pattern"
},
{
"flag": "-f file",
"meaning": "Read patterns from file"
},
{
"flag": "-A / -B / -C N",
"meaning": "Print after / before / both context lines around matches"
},
{
"flag": "--color=never|always|auto",
"meaning": "Highlight matches (default never; auto uses TTY and respects NO_COLOR)"
}
],
"keywords": ["grep", "search", "regex", "pattern", "filter"],
"seeAlso": [
{
"name": "sed",
"section": 1
},
{
"name": "awk",
"section": 1
}
],
"bareOsNotes": "UTF-16 strings and JS regex differ from strict POSIX/GNU.",
"examples": [
{
"caption": "recursive feel (grep each file)",
"code": "grep -n error *.log"
},
{
"caption": "case insensitive",
"code": "grep -i todo NOTES.md"
},
{
"caption": "invert (lines without)",
"code": "grep -v '^#' config"
},
{
"caption": "fixed string (no regex)",
"code": "grep -F \"v1.0\" CHANGES"
},
{
"caption": "count matches",
"code": "grep -c FAIL build.log"
},
{
"caption": "only filenames",
"code": "grep -l main *.js"
},
{
"caption": "multiple patterns",
"code": "grep -e foo -e bar file.txt"
}
],
"listCategory": "coreutils"
}