Skip to content

searching for control characters #2578

Closed Answered by BurntSushi
njamescouk asked this question in Q&A
Discussion options

You must be logged in to vote

I don't know what rg <alt 31> means, but rg '\x31' should work:

$ printf "\x31" > haystack
$ xxd haystack
00000000: 31                                       1
$ rg '\x31' haystack
1:1
$ rg '\x31' haystack | xxd
00000000: 310a                                     1.

Note that this is on Linux. The important bit here is that ripgrep recognizes the \x31 itself as an escape sequence and interprets it as matching the literal byte (in this case) 0x31. You basically just need to be careful that your shell doesn't do something to mangle it. I'm not familiar with Windows shell quoting, so you'll need to figure that out.

Replies: 2 comments 2 replies

Comment options

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

Answer selected by BurntSushi
Comment options

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants