# How to supply "raw" bytes to git grep?

5 messages from 2008-09-18 to 2008-09-18. Participants: Johan Herland, Jacob Helwig, Jakub Narebski, Kalle Olavi Niemitalo.
Thread: https://gitlist.dev/t/15575

## Johan Herland, 2008-09-18 15:28

Subject: How to supply "raw" bytes to git grep?
Message-ID: <200809181728.18597.johan@herland.net>
URL: https://gitlist.dev/e/200809181728.18597.johan%40herland.net

```
Hi,

I wanted to list all text files in my repo which contain carriage 
returns, so I tried the following command-line:

	git grep --cached -I -l -e <CR>

where <CR> is some magic incantation that I've yet to figure out. I've 
tried all the obvious cases (\r, 0x0d, \015, etc.), but none of them 
seem to DWIM...

The only working solution I've found so far is to create a file 
(named "cr") in a hex editor that contains exactly one CR byte, and 
then use the -f option to 'git grep':

	git grep --cached -I -l -f cr

Is there an easier way? And if not, should I try to create one (e.g. 
teaching 'git grep' to grok backslash escapes)?


Have fun!

...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

```

## Jacob Helwig, 2008-09-18 15:46

Subject: Re: How to supply "raw" bytes to git grep?
Message-ID: <8c9a060809180846j25e4eb44h291b017aa01bbe36@mail.gmail.com>
URL: https://gitlist.dev/e/8c9a060809180846j25e4eb44h291b017aa01bbe36%40mail.gmail.com
In-Reply-To: <200809181728.18597.johan@herland.net>

```
On Thu, Sep 18, 2008 at 08:28, Johan Herland <johan@herland.net> wrote:
> Hi,
>
> I wanted to list all text files in my repo which contain carriage
> returns, so I tried the following command-line:
>
>        git grep --cached -I -l -e <CR>
>
> where <CR> is some magic incantation that I've yet to figure out. I've
> tried all the obvious cases (\r, 0x0d, \015, etc.), but none of them
> seem to DWIM...
>
> The only working solution I've found so far is to create a file
> (named "cr") in a hex editor that contains exactly one CR byte, and
> then use the -f option to 'git grep':
>
>        git grep --cached -I -l -f cr
>
> Is there an easier way? And if not, should I try to create one (e.g.
> teaching 'git grep' to grok backslash escapes)?
>
>
> Have fun!
>
> ...Johan
>
> --
> Johan Herland, <johan@herland.net>
> www.herland.net
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

Inserting a literal carriage return seems to do the trick for me, in bash.

git grep --cached -I -l -e <Ctrl-V><Ctrl-M>

```

## Johan Herland, 2008-09-18 16:18

Subject: Re: How to supply "raw" bytes to git grep?
Message-ID: <200809181818.42745.johan@herland.net>
URL: https://gitlist.dev/e/200809181818.42745.johan%40herland.net
In-Reply-To: <8c9a060809180846j25e4eb44h291b017aa01bbe36@mail.gmail.com>

```
On Thursday 18 September 2008, Jacob Helwig wrote:
> On Thu, Sep 18, 2008 at 08:28, Johan Herland wrote:
> > I wanted to list all text files in my repo which contain carriage
> > returns, so I tried the following command-line:
> >
> >        git grep --cached -I -l -e <CR>
> >
> > where <CR> is some magic incantation that I've yet to figure out.
> > I've tried all the obvious cases (\r, 0x0d, \015, etc.), but none
> > of them seem to DWIM...
>
> Inserting a literal carriage return seems to do the trick for me, in
> bash.
>
> git grep --cached -I -l -e <Ctrl-V><Ctrl-M>

Thanks. That's exactly the incantation I was looking for. ;)


...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

```

## Jakub Narebski, 2008-09-18 16:31

Subject: Re: How to supply "raw" bytes to git grep?
Message-ID: <gatvp0$kl0$1@ger.gmane.org>
URL: https://gitlist.dev/e/gatvp0%24kl0%241%40ger.gmane.org
In-Reply-To: <200809181728.18597.johan@herland.net>

```
Johan Herland wrote:

> I wanted to list all text files in my repo which contain carriage 
> returns, so I tried the following command-line:
> 
>       git grep --cached -I -l -e <CR>
> 
> where <CR> is some magic incantation that I've yet to figure out. I've 
> tried all the obvious cases (\r, 0x0d, \015, etc.), but none of them 
> seem to DWIM...

Why not use _literal_ CR; of course protecting it by piockung it by
shell as end of command by quites, for example

  $ git grep --cached -I -l -e '
  '

It works for me (bash).
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```

## Kalle Olavi Niemitalo, 2008-09-18 22:07

Subject: Re: How to supply "raw" bytes to git grep?
Message-ID: <871vzhglab.fsf@Astalo.kon.iki.fi>
URL: https://gitlist.dev/e/871vzhglab.fsf%40Astalo.kon.iki.fi
In-Reply-To: <8c9a060809180846j25e4eb44h291b017aa01bbe36@mail.gmail.com>

```
"Jacob Helwig" <jacob.helwig@gmail.com> writes:

> Inserting a literal carriage return seems to do the trick for me, in bash.
>
> git grep --cached -I -l -e <Ctrl-V><Ctrl-M>

In bash, $'\r' works too, and may be nicer to edit.
Better not use that with #! /bin/sh though.

```
