text enabled verified low v1.0.0

grep

Powerful text search utility for pattern matching using regular expressions across files and streams.

📋 Live Preview
grep {extended-regexp} {fixed-strings} {basic-regexp} {perl-regexp} {regexp}
๐Ÿ“Ž extended-regexp ๐Ÿ“Ž fixed-strings ๐Ÿ“Ž basic-regexp ๐Ÿ“Ž perl-regexp ๐Ÿ“Ž regexp
grep {extended-regexp} {fixed-strings} {basic-regexp} {perl-regexp} {regexp}

Sandbox: execFile · Timeout: 60s

Capabilities

text.search.regex
text.search.fixed
text.search.recursive
text.search.invert
text.search.context
data.extract.pattern

Parameters

Name Type Required Default Description Aliases
extended-regexp string No - PATTERNS are extended regular expressions -E, --extended-regexp
fixed-strings string No - PATTERNS are strings -F, --fixed-strings
basic-regexp string No - PATTERNS are basic regular expressions -G, --basic-regexp
perl-regexp string No - PATTERNS are Perl regular expressions -P, --perl-regexp
regexp string No - use PATTERNS for matching -e, --regexp
file file No - take PATTERNS from FILE -f, --file
ignore-case string No - ignore case distinctions in patterns and data -i, --ignore-case
no-ignore-case string No - do not ignore case distinctions (default) --no-ignore-case
word-regexp string No - match only whole words -w, --word-regexp
line-regexp string No - match only whole lines -x, --line-regexp
null-data string No - a data line ends in 0 byte, not newline -z, --null-data
no-messages string No - suppress error messages -s, --no-messages
invert-match string No - select non-matching lines -v, --invert-match
version string No - display version information and exit -V, --version
help string No - display this help text and exit --help
max-count integer No - stop after NUM selected lines -m, --max-count
byte-offset string No - print the byte offset with output lines -b, --byte-offset
line-number string No - print line number with output lines -n, --line-number
line-buffered string No - flush output on every line --line-buffered
with-filename string No - print file name with output lines -H, --with-filename
no-filename string No - suppress the file name prefix on output -h, --no-filename
label file No - use LABEL as the standard input file name prefix --label
only-matching string No - show only nonempty parts of lines that match -o, --only-matching
quiet string No - suppress all normal output -q, --quiet, --silent
binary-files string No - assume that binary files are TYPE --binary-files
text string No - equivalent to --binary-files=text -a, --text
directories string No - ACTION is 'read', 'recurse', or 'skip' -d, --directories
devices string No - how to handle devices, FIFOs and sockets -D, --devices
recursive string No - like --directories=recurse -r, --recursive
dereference-recursive string No - --include=GLOB search only files that match GLOB (a file pattern) --exclude=GLOB skip files that match GLOB --exclude-from=FILE skip files that match any file pattern from FILE --exclude-dir=GLOB s... -R, --dereference-recursive
NUM boolean No - -NUM, --context
after-context integer No - print NUM lines of trailing context -A, --after-context
before-context integer No - -B, --before-context
binary string No - do not strip CR characters at EOL (MSDOS/Windows) -U, --binary
colour boolean No - use markers to highlight the matching strings; --colour
context integer No - print NUM lines of output context -C, --context
count string No - print only a count of selected lines per FILE -c, --count
exclude_dir boolean No - skip directories that match GLOB --exclude-dir
exclude_from boolean No - skip files that match any file pattern from FILE --exclude-from
files-with-matches string No - -l, --files-with-matches
files-without-match string No - -L, --files-without-match
flag-N string No - same as --context=NUM -N
group-separator string No - --no-group-separator do not print separator for matches with context --color[=WHEN], --colour[=WHEN] use markers to highlight the matching strings; WHEN is 'always', 'never', or 'auto' --group-separator
initial-tab string No - make tabs line up (if needed) -T, --initial-tab
no_group_separator boolean No - do not print separator for matches with context --no-group-separator
null string No - print 0 byte after FILE name -Z, --null

Artifacts

TypeDescriptionMIMESchemaTrust
text.search.resultLines matching the search patterntext/plain-verified
text.search.countCount of matching linestext/plain-verified

Contract

Inputs

text.plain

Text input to search through

text.regex.pattern

Regular expression or fixed string pattern

Outputs

text.search.result

Lines matching the search pattern

Side effects:

Workflow Edges

Produces

text.search.result

Consumes

text.plaintext.regex.pattern

Resource Profile

ResourceValue
CPUlow
Memory16 MB
Networknone
Disk I/Omedium

Examples

Search for a pattern in a file

grep 'error' logfile.txt

Case-insensitive recursive search

grep -ri 'TODO' src/

Show context lines around matches

grep -C 3 'Exception' app.log

Count matches per file

grep -c 'function' *.py

Invert match (lines not containing pattern)

grep -v '^#' config.conf

Extract IP addresses with regex

grep -oE '\b([0-9]{1,3}\.){3}[0-9]{1,3}\b' access.log

Darkiros UTILS: Extract md5 hash ({32})

egrep -oE '(^|[^a-fA-F0-9])[a-fA-F0-9]{32}([^a-fA-F0-9]|$)' [file] | egrep -o '[a-fA-F0-9]{32}' > md5-hashes.txt

Darkiros UTILS: Extract sha1 hash ({40})

egrep -oE '(^|[^a-fA-F0-9])[a-fA-F0-9]{40}([^a-fA-F0-9]|$)' [file] | egrep -o '[a-fA-F0-9]{40}' > sha1-hashes.txt

Darkiros UTILS: Extract sha256 hash ({64})

egrep -oE '(^|[^a-fA-F0-9])[a-fA-F0-9]{64}([^a-fA-F0-9]|$)' [file] | egrep -o '[a-fA-F0-9]{64}' > sha256-hashes.txt

Darkiros UTILS: Extract sha512 hash ({128})

egrep -oE '(^|[^a-fA-F0-9])[a-fA-F0-9]{128}([^a-fA-F0-9]|$)' [file] | egrep -o '[a-fA-F0-9]{128}' > sha512-hashes.txt

Darkiros UTILS: Extract valid MySQL-old hash

grep -e "[0-7][0-9a-f]{7}[0-7][0-9a-f]{7}" [file] > mysql-old-hashes.txt

Darkiros UTILS: Extract valid blowfish hash

grep -e "$2a\\$\\08\\$(.){75}" [file] > blowfish-hashes.txt

Darkiros UTILS: Extract emails from file

grep -E -o "\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\\b" [file]

Darkiros UTILS: Extract IP from file

grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" file.txt

NetRunners usefull/shell

grep -r --color=always 'password' .

Documentation

Grep โ€” Text Pattern Search

Grep is one of the essential Unix tools. It searches files and streams for lines matching a pattern, making it invaluable for log analysis, code searching, and data extraction pipelines.

Search Patterns

Basic vs Extended Regex

# Basic regex (default): + and ? are literal
grep 'foo\+' file.txt

# Extended regex: + and ? are metacharacters
grep -E 'foo+' file.txt

# Fixed strings (no regex, faster)
grep -F 'foo+' file.txt

Common Regex Patterns

# Lines starting with a pattern
grep '^error' file.txt

# Lines ending with a pattern
grep 'done$' file.txt

# Word boundaries
grep -w 'class' file.txt

# Character classes
grep '[0-9]\{3\}-[0-9]\{4\}' file.txt

Pipelined Usage

# Chain with other tools
ps aux | grep python | grep -v grep

# Extract and count unique matches
grep -oP 'https?://[^\s"]+' file.txt | sort | uniq -c | sort -rn

# Find files containing pattern
grep -rl 'main' --include='*.py' src/

Performance Tips

Situation Best Tool
Single file grep is fast enough
Large codebase ripgrep (rg) is 5-10x faster
Binary search grep -a or strings | grep
Compressed files zgrep for .gz files

Related Tools

  • ripgrep (rg) โ€” Faster recursive search
  • sed โ€” Stream editor for find-and-replace
  • awk โ€” Text processing and field extraction

Related Tools

rgackawksedagsystem-file-trtext-process-awktext-process-sed

References