Skip to content

how to use replacements when using PowerShell in Windows #2215

Answered by huangjj27
huangjj27 asked this question in Q&A
Discussion options

You must be logged in to vote

It seems neither of the commands works on Powershell:

> rg -N '^(\w+)$' file.txt -r "'\$1',"          
'\',
'\',
> rg -N '^(\w+)$' file.txt -r "'"'$1'"'"','  
$1: The system cannot find the file specified. (os error 2)
': The system cannot find the file specified. (os error 2)
,: The system cannot find the file specified. (os error 2)
file.txt
'
'

and I tried both of the commands in my WSL, both works:

$ rg -N '^(\w+)$' file.txt -r "'\$1',"
'10a3789',
'51b7883',
$ rg -N '^(\w+)$' file.txt -r "'"'$1'"'"','
'10a3789',
'51b7883',

hope these information will help others

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@BillHally
Comment options

Answer selected by BurntSushi
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2214 on May 18, 2022 15:37.