Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get the locate to work on Windows through Git Bash?

Git Bash seems to have nice support of various Linux commands. It even supports locate, though it never finds anything:

mypc@mypc MINGW64 ~
$ locate --regex .*?\/[^\/]+\.docx

I tried to update the locate database, but the support is not finished there:

mypc@mypc MINGW64 ~
$ updatedb
/usr/bin/updatedb: line 323: /usr/var/locatedb.n: No such file or directory
Failed to generate /usr/var/locatedb.n

Can I fix that by editing some script? What causes this problem?

like image 487
Tomáš Zato - Reinstate Monica Avatar asked Apr 25 '16 12:04

Tomáš Zato - Reinstate Monica


2 Answers

from git bash run:

mkdir /c/Program\ Files/Git/usr/var; updatedb --localpaths='/c/'

Also you can add the following alias in your ~/.bash_profile:

alias updatedb="updatedb --localpaths='/c/'"

I havent tried the alias out yet bit I don't see why it would work.

Just make sure to either

source ~/.bash_profile

or open a new shell after you have added the alias so it gets loaded.

like image 167
danielpflood Avatar answered Nov 13 '22 15:11

danielpflood


Thanks for the tip! Just wanted to add to @danielpflood's answer, that I needed to run "Git Bash" as administrator, to be able to create the needed /var/ directory. This is on Windows 10.

[wanted to add as a comment, but I do not have enough reputation for that.]

like image 28
jma73 Avatar answered Nov 13 '22 13:11

jma73