I have
$ ls -l re*trict
ls: cannot access re*trict: No such file or directory
Why does this give 0 matches?
$ locate -c 're*trict'
0
$ locate -c re*trict
0
$ locate -c re?trict
0
This works though and gives 8351 matches:
$ locate -c restrict
8351
locate
matches against the full path name. To findre*trict
as a substring, you have to add*
before and after it:I think the answer is available on the man page:
If any PATTERN contains no glob‐bing characters, locate behaves as if the pattern were *PATTERN*.
Since my PATTERN contains a globbing character it is not expanded to *PATTERN* and so a literal match is tried to be found. Obviously there is no file with name (substituting s)
'restrict'
since even under root the name of such file would be/re?trict
and the match would fail because of a leading/