Skip to content

CommandLineOptions

Dmitry Gusarov edited this page Jun 21, 2020 · 6 revisions

Default implicit arguments

grepl <RegExPattern> <FileMask>

grepl Version=\d.\d.\d *.js

Patterns

Grepl RegEx uses .Net Core and you can find detailed patterns documentation here

Option Effect
-e Specify expression(s)
-f Load expression(s) from file
--patterns-dir <DIR> Add directory to lookup expression files from. You can have multiple dirs, plus current dir, plus grepl binaries dir
--var <NAME> <VALUE> define a variable for templates
Pattern Example
Inline
grepl Version= *.csproj -r
Inline grepl -e Version= *.txt
Two Inline grepl -e Version= -e FileVersion= *.txt
Load from external File grepl -f my.rx *.txt
Mixture grepl -e Version= -f my.rx *.txt
Templated inline grepl (?'lib'),\sVersion= *.csproj -r --var lib System.Web
Templated external grepl -f my.rx *.csproj -r --var lib System.Web

File selectors

Target Example
Single file
grepl <RegEx> test.txt
Two files grepl <RegEx> test.txt test2.txt
Multiple files in single directory grepl <RegEx> *.txt
Multiple files recursively grepl <RegEx> *.txt -r

Replace specifiers

NOTE: By default grepl does not saves changes! You can play around as long as you need and when you are ready, add --save to persist the cahnges

Option Effect
-$ <Replacement> Specify a replacement for matched text
--save Actually save changes. By default it works in preview mode (dry run)
Target Example
Cat to Dog grepl cat -$ dog *.html -r
Clone this wiki locally