On Tuesday, December 03, 2019 09:01:16 AM Greg Wooledge wrote: > 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$'
Thanks that works! (Well, exept for bare repositories, which I'm really not concerned about, at least at this time!) I always have trouble with all the rigamarole around quoting for the shell vs. quoting for the regex (or quoting or not quoting for anything else). I don't know what it will take to get it to sink into my head. (Maybe in my next life ;-) I do find it useful to think of the backslash as "escaping" vs. "quoting". > Again, the single quotes protect the regex from interpretation by the > shell.