Skip to content

WindowsGrep.CommandFlags

Samuel Turner-Lill edited this page Sep 1, 2023 · 9 revisions

Command Flags

Recursive Search   (-f   --recursive)
Changes the scope of the command from "top level directory only" to "top level directory and all sub-directories"

Target Directory   (-d   --directory=)
Sets the root directory for the command. Take directory as a parameter (Encapsulate in single-quotes '' or double-quotes "")
ex.    -d 'C:\Users'   or   --directory='C:\Users'

Context Characters   (-c   --context=)
Sets the number of surrounding characters to be returned with each query result. Takes an integer as a parameter
ex.    -c 50   or   --context=50

Limit n Results   (-n   --results=)
Limits the number of results returned. Takes an integer as a parameter

Suppress Output   (-s   --suppress)
Suppresses console output. Improves search time significantly for queries with large numbers of results

Ignore Line Breaks   (-b   --ignore-breaks)
Ignores new line characters (\r\n) in queried files

Ignore Case   (-i   --ignore-case)
Ignores character-case mistmatches between the users' search term and queried file content

Target File   (-f   --file=)
Sets the scope of the query to a single file. Takes filepath as a parameter (Encapsulate in single-quotes '' or double-quotes "")
ex.    -f 'MyFile.txt'   or   --file='MyFile.txt'

Plain Text Search   (-F   --fixed-strings)
Configures the query to interpret the users' search term literally
ex. How is Hannah? matches How is Hannah?
ex. How is Hannah? does not match How is Hanna

Regular Expression Search   (-G   --basic-regexp)
Configures the query to interpret the users' search term as a regular expression (WindowsGrep default search style)
ex. How is Hannah? matches How is Hannah
ex. How is Hannah? matches How is Hanna

Filter on FileType(s)   (-t   --filetype-filter=)
Restricts scope of files in query to those whose extension matches one of the provided extensions. Takes comma or semi-colon delimited list as a parameter
ex.    -t .cs;.txt   or   --filetype-filter=.cs;.txt

Filter out FileType(s)   (-T   --filetype-exclude-filter=)
Restricts scope of files in query to those whose extension does not match any of the provided extensions. Takes comma or semi-colon delimited list as a parameter
ex.    -T .jpg;.resx   or   --filetype-exclude-filter=.jpg;.resx

Filter Filepaths by Expression [Inclusive]   (-p   --path-filter=)
Restricts scope of files in query to those whose filepath matches one of the user provided expressions (Regular Expressions)
ex.    -p bin\Release*;bin\Debug\*   or   --path-filter=bin\Release*;bin\Debug\*

Filter Filepaths by Expression [Exclusive]   (-P   --path-exclude-filter=)
Restricts scope of files in query to those whose filepath does not match any of the user provided expressions (Regular Expressions)
ex.    -P obj;bin\Debug   or   --path-exclude-filter=obj;bin\Debug

Filenames Only   (-k   --filenames-only)
Modifies query to match against files names rather than file content

FileSize Minimum   (-z   --filesize-minimum=)
Filters out matched files whose managed disk size is less than or equal to the specified size (kilobytes by default). Takes an integer as a parameter (Optional: append kb/mb/gb/tb to change the parameter size type). This is the same size shown in Windows Explorer and within file properties
ex.    -z 1000   or   --filesize-minimum=1000
ex.    -z 1mb   or   --filesize-minimum=1mb

FileSize Maximum  (-Z   --filesize-maximum=)
Filters out matched files whose managed disk size is greater than or equal to the specified size (kilobytes by default). Takes an integer as a parameter (Optional: append kb/mb/gb/tb to change the parameter size type). This is the same size shown in Windows Explorer and within file properties
ex.    -Z 1000   or   --filesize-maximum=1000
ex.    -Z 1mb   or   --filesize-maximum=1mb

Replace Text   (-RX   --replace=)
Permanently replaces matched text in returned files with supplied text. Takes string as a parameter (Encapsulate in single-quotes '' or double-quotes "")
ex.    -RX 'Hello there'   or   --replace='Hello there'

Delete Files   (-DX   --delete)
Deletes all files returned in query

Write Output to File   (-w   --write=)
Write query results to an external file. Space delimited by default. Formats as comma-separated when saved with .csv extension. Takes filepath as a parameter (Encapsulate in single-quotes '' or double-quotes "")
ex.    -w 'MyGrepResuls.txt'   or   --write='MyGrepResuls.txt'
ex.    -w 'MyGrepResuls.csv'   or   --write='MyGrepResuls.csv'

Match against file hashes   (--hash=)
Matches files based on their hash. Takes a hash algorithm type as a parameter (0=SH256, 1=MD5).
ex.    --hash=0 2CE660A74CF0F08B9D1B76AB7F74CDAA65F458FB78AD95CBC16045AA2D7BC01E

Clone this wiki locally