You are not logged in.

#1 2013-08-05 19:32:40

luuuciano
Member
Registered: 2007-01-27
Posts: 311

[solved] locate do not find things using wildcards? :-/

For some odd reason when I do
locate *.odt
do not find anything (well, it just find 1 file, in ~/)

And when I do
locate odt
it finds all the other files (including the ones that have "odt" in the name, path, etc...)

What can be wrong?
I have friends using wildcards & locate, and they have it working "ok"

$ pacman -Qo /usr/bin/locate
/usr/bin/locate es propiedad de mlocate 0.26-1

$ whereis locate
locate: /usr/bin/locate /usr/share/man/man1/locate.1.gz

$ cat /etc/updatedb.conf
PRUNE_BIND_MOUNTS = "yes"
PRUNEFS = "9p afs anon_inodefs auto autofs bdev binfmt_misc cgroup cifs coda configfs cpuset cramfs debugfs devpts devtmpfs ecryptfs exofs ftpfs fuse fuse.encfs fuse.sshfs fusectl gfs gfs2 hugetlbfs inotifyfs iso9660 jffs2 lustre mqueue ncpfs nfs nfs4 nfsd pipefs proc ramfs rootfs rpc_pipefs securityfs selinuxfs sfs shfs smbfs sockfs sshfs sysfs tmpfs ubifs udf usbfs vboxsf"
PRUNENAMES = ".git .hg .svn"
PRUNEPATHS = "/afs /media /mnt /net /sfs /tmp /udev /var/cache /var/lib/pacman/local /var/lock /var/run /var/spool /var/tmp"

Any idea?

Last edited by luuuciano (2013-08-05 19:45:08)


I arch, you arch, he arch, she arch, we arch, they arch...

Offline

#2 2013-08-05 19:35:59

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] locate do not find things using wildcards? :-/

Run 'updatedb' and try again.


Edit: Also: https://bbs.archlinux.org/viewtopic.php?id=167104

Last edited by karol (2013-08-05 19:36:55)

Offline

#3 2013-08-05 19:36:50

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,724
Website

Re: [solved] locate do not find things using wildcards? :-/

I would assume that your shell is expanding the wildcard instead of passing it to locate, so 'locate *.odt' in your home area expands to 'locate abc.odt', instead of locating all files ending in ".odt".

I don't use locate, so I don't know if it supports wildcards, but try escaping your asterisk with a backslash.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#4 2013-08-05 19:39:22

luuuciano
Member
Registered: 2007-01-27
Posts: 311

Re: [solved] locate do not find things using wildcards? :-/

karol wrote:

Run 'updatedb' and try again.


Edit: Also: https://bbs.archlinux.org/viewtopic.php?id=167104

Sure, I did it...
Anyway, the db was updated properly, as  the second command (without wildwcard) shows all the files (including other garbages)...

Thanks for the link, will read it


I arch, you arch, he arch, she arch, we arch, they arch...

Offline

#5 2013-08-05 19:40:25

luuuciano
Member
Registered: 2007-01-27
Posts: 311

Re: [solved] locate do not find things using wildcards? :-/

WorMzy wrote:

I don't use locate, so I don't know if it supports wildcards, but try escaping your asterisk with a backslash.

That worked!


I arch, you arch, he arch, she arch, we arch, they arch...

Offline

#6 2013-08-05 22:38:39

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: [solved] locate do not find things using wildcards? :-/

You can also use single quotes to stop the shell interpolating wildcards.  I've learned to search for a file by using the format locate '*/file'.  Try the difference between these two commands:

$ locate python        # Returns too much!
$ locate '*/python'        # Returns 8 files on my machine.

Offline

#7 2013-08-05 22:44:30

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] locate do not find things using wildcards? :-/

A little bit OT:

I'm using bash with

shopt -s globstar
shopt -s extglob

- is this why I don't have to use quotes or escape wildcards ?

Offline

#8 2013-08-05 23:14:44

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,724
Website

Re: [solved] locate do not find things using wildcards? :-/

I think your wildcards just aren't matching anything in your current directory:

'man bash':

   Pathname Expansion
       After word splitting, unless the -f option has been set, bash  scans  each  word  for  the
       characters  *, ?, and [.  If one of these characters appears, then the word is regarded as
       a pattern, and replaced with an alphabetically sorted list of file names matching the pat‐
       tern.   If no matching file names are found, and the shell option nullglob is not enabled,
       the word is left unchanged.  If the nullglob option is set, and no matches are found,  the
       word  is removed.  If the failglob shell option is set, and no matches are found, an error
       message is printed and the command is not executed.  If the  shell  option  nocaseglob  is
       enabled, the match is performed without regard to the case of alphabetic characters.  When
       a pattern is used for pathname expansion, the character ``.''  at the start of a  name  or
       immediately  following a slash must be matched explicitly, unless the shell option dotglob
       is set.  When matching a pathname, the slash character must always be matched  explicitly.
       In  other  cases,  the  ``.''  character is not treated specially.  See the description of
       shopt below under SHELL BUILTIN COMMANDS for a description of  the  nocaseglob,  nullglob,
       failglob, and dotglob shell options.

       The  GLOBIGNORE  shell  variable  may be used to restrict the set of file names matching a
       pattern.  If GLOBIGNORE is set, each matching file name that also matches one of the  pat‐
       terns in GLOBIGNORE is removed from the list of matches.  The file names ``.''  and ``..''
       are always ignored when GLOBIGNORE is set and not null.  However, setting GLOBIGNORE to  a
       non-null  value  has  the  effect  of enabling the dotglob shell option, so all other file
       names beginning with a ``.''  will match.  To get the old behavior of ignoring file  names
       beginning  with  a  ``.'',  make  ``.*''   one of the patterns in GLOBIGNORE.  The dotglob
       option is disabled when GLOBIGNORE is unset.

...

              extglob If set, the extended pattern matching features described above under  Path‐
                      name Expansion are enabled.

Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#9 2013-08-05 23:54:49

luuuciano
Member
Registered: 2007-01-27
Posts: 311

Re: [solved] locate do not find things using wildcards? :-/

Thanks a lot to everyone giving findings, thoughts and information... I have learned a lot today


I arch, you arch, he arch, she arch, we arch, they arch...

Offline

#10 2013-08-06 00:48:36

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] locate do not find things using wildcards? :-/

Thanks, I'll have to read the whole bash manual one day ... although I suppose it'll take about a week, not just a single day ;P

Offline

Board footer

Powered by FluxBB