Gentoo Archives: gentoo-user

From: Kai Krakow <hurikhan77@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] Re: locate can not find a file
Date: Wed, 15 Mar 2017 21:36:50
Message-Id: 20170315223614.4eb0148a@jupiter.sol.kaishome.de
In Reply to: Re: [gentoo-user] locate can not find a file by Alarig Le Lay
1 Am Wed, 15 Mar 2017 16:31:58 +0100
2 schrieb Alarig Le Lay <alarig@××××××××××.fr>:
3
4 > On mer. 15 mars 09:10:26 2017, thelma@×××××××××××.com wrote:
5 > > Yes, I run as root: updatedb
6 > > But when run:
7 > > locate consent_extraction*
8 > >
9 > > It only list one file:
10 > > /home/fd/consent_extraction1.pdf (this is a link file)
11 > > /home/fd/business/forms/consent_extraction1.pdf
12 > >
13 > > It can not find: "consent_extraction.pdf" both files are in same
14 > > directory
15 > >
16 > > ll business/forms/
17 > > total 688
18 > > ...
19 > > -rw-r--r-- 1 fd fd 63032 Mar 15 08:52 consent_extraction1.pdf
20 > > -rw-r--r-- 1 fd fd 397649 Mar 14 20:05 consent_extraction.pdf
21 > >
22 > > I observe the same behaviour on my local machine and remote machine.
23 > >
24 > > Running "find" finds both files
25 > >
26 > > find . -name '*consent_extraction*'
27 > > ./business/forms/consent_extraction.pdf
28 > > ./business/forms/consent_extraction1.pdf
29 > > ./consent_extraction1.pdf
30 > >
31 > > Why?
32 >
33 > Hi,
34 >
35 > Do you have file consent_extraction1.pdf in your working directory? In
36 > that case, your shell will begin by expending your asterisk and you
37 > will really look for consent_extraction1.pdf.
38
39 This is a concept many people cannot or don't want to grasp. Easy fix
40 is to put quotation marks around the search term:
41
42 # locate "consent_extraction*"
43
44 Especially people coming from Windows or DOS have problems with this
45 feature. In the MS world, globbing expansion is done by the command
46 itself: it will see the * literally in the parameters.
47
48 In the GNU world, globbing expansion is done by the shell before
49 handing parameters over to the command: The command won't see the * but
50 instead sees what the shell made from it. To work around this behavior,
51 you simply put quotation marks around it (which will be removed before
52 handed over to the command, so even consent_extraction"*" would work).
53
54 Thus, simply always put quotation marks if you don't want to become
55 fooled by unwillingly letting the shell do its job. Missing to do so
56 can even have some negative effects, i.e. dangerous, like overwriting
57 files during mv by moving all files into the same filename.
58
59 --
60 Regards,
61 Kai
62
63 Replies to list-only preferred.

Replies

Subject Author
[gentoo-user] Re: locate can not find a file Grant Edwards <grant.b.edwards@×××××.com>
Re: [gentoo-user] Re: locate can not find a file thelma@×××××××××××.com