Files
bare-operating-system/packages/bare-os-coreutils/man/pages/grep.json
T

108 lines
2.2 KiB
JSON

{
"name": "grep",
"section": 1,
"title": "pattern matching utility",
"synopsis": [
"grep [-E|-F] [-i] [-v] [-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": "-i",
"meaning": "Ignore case"
},
{
"flag": "-v",
"meaning": "Invert match"
},
{
"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"
}
],
"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"
}
]
}