locate behavior with bash wildcards


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 find re*trict as a substring, you have to add * before and after it:

locate '*re*trict*'


I think the answer is available on the man page:

<em>If any PATTERN contains no glob‐bing characters, locate behaves as if the pattern were *PATTERN*.</em>

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 /


  • Convert array of strings to array of objects
  • Does Perl currently (5.8 and 5.10) make any promises about the order alternations will be used?
  • pyspark substring and aggregation
  • Replace last two characters in column
  • How can I display the parent menu item's description using Wordpress walkers?
  • Android app gives error “BatteryStatsImpl: reading network stats”
  • How to get current document uri in XSLT?
  • Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+
  • Silverlight DependencyProperty.SetCurrentValue Equivalent
  • How to use JavaScript to determine whether a file exists in a directory?
  • How do I access an unhandled exception in an MVC Error view?
  • print() is showing quotation marks in results
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • Replace value with Factor in r data.table
  • Checking free space on FTP server
  • Android fill_parent issue
  • Get object from AWS S3 as a stream
  • How to recover from a Spring Social ExpiredAuthorizationException
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • script to move all files from one location to another location
  • Javascript Callbacks with Object constructor
  • ILMerge & Keep Assembly Name
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Symfony2: How to get request parameter
  • Weird JavaScript statement, what does it mean?
  • Large data - storage and query
  • Apache 2.4 - remove | delete | uninstall
  • WOWZA + RTMP + HTML5 Playback?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • Benchmarking RAM performance - UWP and C#
  • Angular 2 constructor injection vs direct access
  • Java static initializers and reflection
  • Android Google Maps API OnLocationChanged only called once
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • Is there any way to bind data to data.frame by some index?
  • How can i traverse a binary tree from right to left in java?
  • UserPrincipal.Current returns apppool on IIS