Skip to content
Discussion options

You must be logged in to vote

Since you're on Windows, I can't tell whether your input files use CRLF or LF line endings. Have you tried the --crlf flag? This is relevant because it changes $ from matching only \n to also matching \r\n.

Maybe your grep program is using CRLF automatically? It's hard to tell with the information you've provided. But it's easy to demonstrate the difference between LF and CRLF. First, LF:

$ xxd /tmp/1.h
00000000: 2370 7261 676d 6120 6f6e 6365 0a0a 2364  #pragma once..#d
00000010: 6566 696e 6520 464f 4f28 7829 205c 0a20  efine FOO(x) \.
00000020: 2020 2073 7461 7469 6320 696e 7420 6120     static int a
00000030: 3d20 783b 205c 0a20 2020 202b 2b61 3b0a  = x; \.    ++a;.
$ grep "static.*\\\\…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@andrey-starodubtsev
Comment options

@BurntSushi
Comment options

@andrey-starodubtsev
Comment options

Answer selected by andrey-starodubtsev
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
Converted from issue

This discussion was converted from issue #3233 on December 01, 2025 12:25.