Help with --regex in locate
Notes:
* In general, reply to the list, I am subscribed under a slightly different
username and will see any replies.
* As is often the case, there is more than one way to skin this cat,
although I won't mind other approaches, especially if they are simpler, I
would like to learn what I'm doing wrong with locate --regex.
Overall objective:
I have several .git repositories on this computer. I want to get a list of
those repositories without getting a listing of all the files in each
repository.
Each repository is in a different subdirectory, and with varying path lengths
(both in number of characters and number of parent directories).
Each repository has several files, including one file ending with .git, e.g.:
/rhk03/Dusan_scintilla_git/RS041-scintilla-syntax-highlighter/.giti
/rhk03/Dusan_scintilla_git/scintilla-scite/.git
/rhk03/Dusan_scintilla_git/scintilla-scite-pre20190419/.git
/rhk03/chroot/scintilla-scite/Scintilla-SciTE/.git
/rhk03/chroot/scintilla-scite/Scintilla-SciTE.git/.git
/rhk03/chroot/scintilla-scite-pre20190419/.git
/rhk03/chroot/scintilla-scite-preKDevelop/.git
(Just for the record, I edited the .gitignore results shown below to the the
.git results shown above, to show what I'm trying to get.)
I believe I have achieved my objective by searching and finding similar lines
that end with .gitignore, using this locate command (I've achieved my
objective if every .git repository includes a file named .gitignore -- at the
moment, I believe that is true):
locate --regex \/\.gitignore
which finds:
/rhk03/Dusan_scintilla_git/RS041-scintilla-syntax-highlighter/.gitignore
/rhk03/Dusan_scintilla_git/scintilla-scite/.gitignore
/rhk03/Dusan_scintilla_git/scintilla-scite-pre20190419/.gitignore
/rhk03/chroot/scintilla-scite/Scintilla-SciTE/.gitignore
/rhk03/chroot/scintilla-scite/Scintilla-SciTE.git/.gitignore
/rhk03/chroot/scintilla-scite-pre20190419/.gitignore
/rhk03/chroot/scintilla-scite-preKDevelop/.gitignore
But I've had no luck finding only the paths that end in .git. I've tried a
number of locate commands (in almost a shotgun approach) none of them have
worked, and some have given me some really strange results (finding files in
/usr that have git somewhere in the filename, but not just .git)
Some of the commands I tried:
rhk@s31:/rhk03$ locate --regex \/\.git
rhk@s31:/rhk03$ locate --regex \/\.git[^\/]
rhk@s31:/rhk03$ locate --regex \/\.git[^\/][:blank:]
rhk@s31:/rhk03$ locate --regex \/git[^\.][:blank:]
rhk@s31:/rhk03$ locate --regex \.git[^\.][:blank:]
rhk@s31:/rhk03$ locate --regex \.git[\.][:blank:]
rhk@s31:/rhk03$ locate --regex \.git[:blank:]
Any help / insights will be appreciated!
Reply to: