Am Wed, 15 Mar 2017 15:52:53 -0600 schrieb the...@sys-concept.com: > On 03/15/2017 03:36 PM, Kai Krakow wrote: > > Am Wed, 15 Mar 2017 16:31:58 +0100 > > schrieb Alarig Le Lay <ala...@swordarmor.fr>: > > > >> On mer. 15 mars 09:10:26 2017, the...@sys-concept.com wrote: > [...] > >> > >> Hi, > >> > >> Do you have file consent_extraction1.pdf in your working > >> directory? In that case, your shell will begin by expending your > >> asterisk and you will really look for consent_extraction1.pdf. > > > > This is a concept many people cannot or don't want to grasp. Easy > > fix is to put quotation marks around the search term: > > > > # locate "consent_extraction*" > > > > Especially people coming from Windows or DOS have problems with this > > feature. In the MS world, globbing expansion is done by the command > > itself: it will see the * literally in the parameters. > > > > In the GNU world, globbing expansion is done by the shell before > > handing parameters over to the command: The command won't see the * > > but instead sees what the shell made from it. To work around this > > behavior, you simply put quotation marks around it (which will be > > removed before handed over to the command, so even > > consent_extraction"*" would work). > > > > Thus, simply always put quotation marks if you don't want to become > > fooled by unwillingly letting the shell do its job. Missing to do so > > can even have some negative effects, i.e. dangerous, like > > overwriting files during mv by moving all files into the same > > filename. > > locate "consent_extraction*" - didn't find anything > > I think, by default "locate" wants to enclose the search location > between two "*.....*" stars. So if you will not put anything locate > will put them for you. If you put only one star it will not find > anything.
Not true... But it seems globbing is working different in locate (well, technically speaking, it works different as expected): The star always matches against the complete path, not only one path fragment. That is why it doesn't work for you. Use the following and it should work: # locate $(pwd)/"consent_extraction*" If you put a star in front, it will also match the $(pwd) component. On the shell, omitting the star in the front only works because you are already in that directory. The shell omits this part of the path when matching. To make this clear, doing: # cd .. # ls consent_extraction* wouldn't find your file, too. But using: # cd .. # ls */consent_extraction* would. As does locate... -- Regards, Kai Replies to list-only preferred.