On Tue, Dec 03, 2019 at 05:54:33AM -0500, Rh Kramer wrote:
> locate --regex \/\.gitignore

Your quoting is all wrong here.  What you want is:

locate --regex '/\.gitignore'

The / does not need to be quoted, either for the shell, or for the
regex.  It's just a regular old character with no special meaning.
The . on the other hand DOES need to be quoted, not for the shell,
but for the regex.  Because in a regex, it means "any character".

Within the regex, you quote it by putting a \ in front of it.  However,
then that backslash needs to be quoted for the SHELL, because otherwise
the shell interprets it:

wooledg:~$ echo \.
.

See, that's not what you want.  You need to pass the payload /\.gitignore
as the regex, so you need to quote that in such a way that the shell
doesn't screw with it.  Thus, the single quotes around it.

wooledg:~$ echo '/\.gitignore'
/\.gitignore

> But I've had no luck finding only the paths that end in .git.

locate --regex '\.git$'

Again, the single quotes protect the regex from interpretation by the
shell.

Reply via email to