TERMINAL: Add grep command (#1381)

This commit is contained in:
muesli4brekkies
2024-06-14 08:00:48 +01:00
committed by GitHub
parent a780880531
commit 4936d14639
4 changed files with 543 additions and 30 deletions
+43
View File
@@ -15,6 +15,8 @@ export const TerminalHelpText: string[] = [
" download [script/text file] Downloads scripts or text files to your computer",
" expr [math expression] Evaluate a mathematical expression",
" free Check the machine's memory (RAM) usage",
" grep [opts]... pattern [file]... Search for PATTERN (string/regular expression) in each FILE and print results to terminal",
" [-O] [target file]",
" grow Spoof money in a servers bank account, increasing the amount available.",
" hack Hack the current machine",
" help [command] Display this help text, or the help text for a command",
@@ -229,6 +231,47 @@ export const HelpTexts: Record<string, string[]> = {
"how much of it is being used.",
" ",
],
grep: [
"Usage: grep [OPTION]... PATTERN [FILE]... [-O] [OUTFILE] [-B/A/C] [NUM]",
" ",
"Search for PATTERN in each FILE and print results to terminal.",
"Example: grep -n -h 'hello world' file1.js file2.txt -O output.txt -C 10 -V",
" ",
"OPTIONS: ",
" --help output this usage message and exit",
" ",
"Search control:",
" -* --search-all search for PATTERN in each FILE on server. Ignores any FILE argument(s) passed",
" -p --pipe-terminal search for PATTERN in terminal output. Ignores any FILE argument(s) passed",
" ",
"Pattern selection and interpretation:",
" -R, --regexp PATTERN is basic regular expression. PATTERN is a string by default",
" ",
"Output control:",
" -m --max-count NUM stop after NUM selected lines",
" -H --with-filename print filename with output lines. Default when multiple FILE arguments passed",
" -h --no-filename suppress printing file name with output lines. Default when one FILE argument passed. Overrides -H",
" -n --line-number print line number with output lines",
" -q --quiet --silent suppress printing to terminal",
" -O --output OUTFILE pipe output to text file. The following argument must be a valid .txt or .json filename. Does NOT overwrite by default",
" -f --allow-overwrite combine with [-O/--output] to allow overwriting provided output file",
" ",
"Context control:",
" -B --before-context NUM print NUM lines of leading context",
" -A --after-context NUM print NUM lines of trailing context",
" -C --context NUM print NUM lines of output context",
" ",
"Miscellaneous:",
" -V --verbose print PATTERN, count of matches and FILE(s) searched after regular output",
" -v --invert-match select non-matching lines",
" ",
"Regular OPTIONs may be combined into one. Context, max-count and output OPTIONs must be separated. Example: grep test -VnH* -O output.txt -C 5",
"By default PATTERN is interpreted as a simple string.",
"At least one FILE argument must be passed, or pass -*/--search-all to search all files.",
"The argument immediately following -m, -O and -B/A/C will be interpreted as the parameter for that OPTION.",
'If encountering difficulties with argument parsing, consider explicitly passing a string as PATTERN. Example: grep -G "(complex|regexp|\\w+)" script.js',
" ",
],
grow: [
"Usage: grow",
" ",