grep
Linux · Text · available in the simulator
What it does
Search for a pattern in one or more files.
Syntax
grep [opciones] patrón [archivo...]
Options and parameters
-iPerform case-insensitive matching.
grep -i error log.txt-rSearch recursively within directories.
grep -rin "error" .-nPrefix output with the line number of each match.
-vInvert match to select non-matching lines.
grep -v "^#" config.conf-EUse extended regular expressions; equivalent to egrep.
grep -E "error|warn" log.txt-cPrint only the count of matching lines.
-RLike -r, but follow all symbolic links.
-lPrint only the names of files with matches.
-wMatch only whole words, not partial matches.
-oPrint only the matched parts of a line.
-FTreat pattern as a literal string; equivalent to fgrep.
-APrint the specified number of trailing context lines.
grep -A3 error log.txt-BPrint the specified number of leading context lines.
-CPrint the specified number of leading and trailing context lines.
--includeLimit recursive search to files that match the pattern.
--excludeSkip files that match the pattern from search.
Usage examples
grep error archivo.txtgrep -i error log.txtgrep -rn TODO src/grep error app.loggrep -rin 'error' .grep -rin "error" .grep -v "^#" config.confgrep -E "error|warn" log.txtgrep -A3 error log.txt