* [gentoo-user] Search filesystem with a wildcard
@ 2011-02-26 2:26 Grant
2011-02-26 3:19 ` Amankwah
2011-02-26 3:23 ` Mike Gilbert
0 siblings, 2 replies; 16+ messages in thread
From: Grant @ 2011-02-26 2:26 UTC (permalink / raw
To: Gentoo mailing list
I used to use slocate like this to search the filesystem for a file:
foo*.txt
but mlocate doesn't seem to accept wildcards. I tried to figure out
how to do it with find but failed. Can anyone point me in the right
direction?
- Grant
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] Search filesystem with a wildcard
2011-02-26 2:26 [gentoo-user] Search filesystem with a wildcard Grant
@ 2011-02-26 3:19 ` Amankwah
2011-02-26 4:33 ` Mike Gilbert
` (2 more replies)
2011-02-26 3:23 ` Mike Gilbert
1 sibling, 3 replies; 16+ messages in thread
From: Amankwah @ 2011-02-26 3:19 UTC (permalink / raw
To: gentoo-user
On Fri, Feb 25, 2011 at 06:26:51PM -0800, Grant wrote:
> I used to use slocate like this to search the filesystem for a file:
>
> foo*.txt
>
> but mlocate doesn't seem to accept wildcards. I tried to figure out
> how to do it with find but failed. Can anyone point me in the right
> direction?
>
> - Grant
How about this?
find -name foo*.txt ?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] Search filesystem with a wildcard
2011-02-26 3:19 ` Amankwah
@ 2011-02-26 4:33 ` Mike Gilbert
2011-02-26 10:24 ` Roman Zilka
2011-02-26 17:33 ` Grant
2 siblings, 0 replies; 16+ messages in thread
From: Mike Gilbert @ 2011-02-26 4:33 UTC (permalink / raw
To: gentoo-user; +Cc: Amankwah
On Fri, Feb 25, 2011 at 10:19 PM, Amankwah <amankwah7@gmail.com> wrote:
> How about this?
>
> find -name foo*.txt ?
Why would you scan the entire file system when you have an speedy index?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] Search filesystem with a wildcard
2011-02-26 3:19 ` Amankwah
2011-02-26 4:33 ` Mike Gilbert
@ 2011-02-26 10:24 ` Roman Zilka
2011-02-26 17:33 ` Grant
2 siblings, 0 replies; 16+ messages in thread
From: Roman Zilka @ 2011-02-26 10:24 UTC (permalink / raw
To: gentoo-user
Amankwah (Sat, 26 Feb 2011 11:19:22 +0800):
> On Fri, Feb 25, 2011 at 06:26:51PM -0800, Grant wrote:
> > I used to use slocate like this to search the filesystem for a file:
> >
> > foo*.txt
> >
> > but mlocate doesn't seem to accept wildcards. I tried to figure out
> > how to do it with find but failed. Can anyone point me in the right
> > direction?
> >
> > - Grant
>
> How about this?
>
> find -name foo*.txt ?
+1 to this solution. Only, it may destroy the universe on some rare
occasions. A safer way:
find / -type f -name 'foo*.txt'
-rz
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] Search filesystem with a wildcard
2011-02-26 3:19 ` Amankwah
2011-02-26 4:33 ` Mike Gilbert
2011-02-26 10:24 ` Roman Zilka
@ 2011-02-26 17:33 ` Grant
2011-02-26 18:26 ` luis jure
` (2 more replies)
2 siblings, 3 replies; 16+ messages in thread
From: Grant @ 2011-02-26 17:33 UTC (permalink / raw
To: gentoo-user
>> I used to use slocate like this to search the filesystem for a file:
>>
>> foo*.txt
>>
>> but mlocate doesn't seem to accept wildcards. I tried to figure out
>> how to do it with find but failed. Can anyone point me in the right
>> direction?
>>
>> - Grant
>
> How about this?
>
> find -name foo*.txt ?
I can't get find to work. This works:
locate *foo*.txt
but none of these work:
find /my/folder -name foo*.txt
find /my/folder -name *foo*.txt
find /my/folder -type f -name '*foo*.txt'
What am I doing wrong? I do need the find to be recursive in that folder.
- Grant
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] Search filesystem with a wildcard
2011-02-26 17:33 ` Grant
@ 2011-02-26 18:26 ` luis jure
2011-02-26 21:45 ` Roman Zilka
2011-02-27 3:46 ` Stroller
2 siblings, 0 replies; 16+ messages in thread
From: luis jure @ 2011-02-26 18:26 UTC (permalink / raw
To: gentoo-user
on 2011-02-26 at 09:33 Grant wrote:
>I can't get find to work. This works:
>
>locate *foo*.txt
>
>but none of these work:
>
>find /my/folder -name foo*.txt
>find /my/folder -name *foo*.txt
>find /my/folder -type f -name '*foo*.txt'
>
>What am I doing wrong? I do need the find to be recursive in that folder.
i'm sorry i haven't been following the thread too closely, but the last
one should work. according to man find, when using wildcards in a search,
"you should enclose the pattern in quotes or escape the wildcard", meaning
that all these work:
find /my/folder -type f -name "*foo*.txt"
find /my/folder -type f -name '*foo*.txt'
find /my/folder -type f -name \*foo\*.txt
they certainly work for me. am i missing something?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] Search filesystem with a wildcard
2011-02-26 17:33 ` Grant
2011-02-26 18:26 ` luis jure
@ 2011-02-26 21:45 ` Roman Zilka
2011-02-27 3:46 ` Stroller
2 siblings, 0 replies; 16+ messages in thread
From: Roman Zilka @ 2011-02-26 21:45 UTC (permalink / raw
To: gentoo-user
> >> I used to use slocate like this to search the filesystem for a file:
> >>
> >> foo*.txt
> >>
> >> but mlocate doesn't seem to accept wildcards. I tried to figure out
> >> how to do it with find but failed. Can anyone point me in the right
> >> direction?
> >>
> >> - Grant
> >
> > How about this?
> >
> > find -name foo*.txt ?
>
> I can't get find to work. This works:
>
> locate *foo*.txt
>
> but none of these work:
>
> find /my/folder -name foo*.txt
> find /my/folder -name *foo*.txt
> find /my/folder -type f -name '*foo*.txt'
>
> What am I doing wrong? I do need the find to be recursive in that folder.
Don't you have some unfortunate alias set up for 'find'? I understand
you already have a working solution, but something's fishy here indeed.
The third one should absolutely work.
By the way, you should probably use quotes with 'locate' too. It might
cause the same kind of unexpected fail in case there happens to be
something which satisfies *foo*.txt in the working directory of the
command.
-rz
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] Search filesystem with a wildcard
2011-02-26 17:33 ` Grant
2011-02-26 18:26 ` luis jure
2011-02-26 21:45 ` Roman Zilka
@ 2011-02-27 3:46 ` Stroller
[not found] ` <73cb39da-826b-4754-91f4-40e9656fe961@ZABRYSVISEXHUB2.af.didata.local>
2011-02-27 19:32 ` Grant
2 siblings, 2 replies; 16+ messages in thread
From: Stroller @ 2011-02-27 3:46 UTC (permalink / raw
To: gentoo-user
On 26/2/2011, at 5:33pm, Grant wrote:
> I can't get find to work. This works:
>
> locate *foo*.txt
>
> but none of these work:
>
> find /my/folder -name foo*.txt
> find /my/folder -name *foo*.txt
> find /my/folder -type f -name '*foo*.txt'
$ mkdir -p /my/folder
mkdir: cannot create directory `/my': Permission denied
$ mkdir -p my/folder
$ touch my/folder/foo.txt
$ find my/folder -type f -name '*foo*.txt'
my/folder/foo.txt
$ find /my/folder -name foo*.txt
find: `/my/folder': No such file or directory
$ ^/^
find my/folder -name foo*.txt
my/folder/foo.txt
$
> What am I doing wrong? I do need the find to be recursive in that folder.
IMO the first thing you're doing wrong is concealing from us what you're actually doing.
You're telling us that `find /my/folder -name foo*.txt` and two other versions don't work, yet you're relying on us taking your word on it that they don't.
Prove it!
You could have done exactly as I did above and create a folder called "my/folder" and created a file called foo.txt and then copied and pasted from the terminal to show us your actual commands.
So we are only left to guess that the file you're looking for is NOT actually called "foo.txt" and it's NOT actually in a folder called "/my/folder". So the problem could be that you're looking for a file with a capital letter in its name, and that you're using "-name" instead of "-iname", or it could be that you're searching the wrong directory tree, or it could be a bunch of other things. Permissions springs to mind.
But you'd rather waste our time in trying to conceal what you're looking for (I can only assume the file is called "Busty big sluts 3.avi") than help us help you.
Stroller.
^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <73cb39da-826b-4754-91f4-40e9656fe961@ZABRYSVISEXHUB2.af.didata.local>]
* Re: [gentoo-user] Search filesystem with a wildcard
[not found] ` <73cb39da-826b-4754-91f4-40e9656fe961@ZABRYSVISEXHUB2.af.didata.local>
@ 2011-02-27 6:52 ` Stroller
2011-02-27 11:29 ` Willie Wong
0 siblings, 1 reply; 16+ messages in thread
From: Stroller @ 2011-02-27 6:52 UTC (permalink / raw
To: gentoo-user
On 27/2/2011, at 6:30am, Alan McKinnon wrote:
> On Sunday 27 February 2011 03:46:48 Stroller wrote:
>> On 26/2/2011, at 5:33pm, Grant wrote:
>>>
>>> find /my/folder -type f -name '*foo*.txt'
>>
>
> He didn't quote the search string and neither did the grandparent. Find will
> do what he's asking and it's most unlikely that's what he wants.
>
> Grant, you have
>
> find /my/folder -name foo*.txt
>
> but you want
>
> find /my/folder -name 'foo*.txt'
AIUI using `find /my/folder -name foo*.txt` (i.e. unquoted) the shell will pass the * to find if it can't expand it itself.
So as long as he doesn't have a foo*.txt in his current working directory then either command should work fine.
$ ls my/folder/
foo.txt
$ ls foo.txt
foo.txt
$ rm foo.txt
$ find my/folder -name foo*.txt
my/folder/foo.txt
$ ls fo*.txt
ls: cannot access fo*.txt: No such file or directory
$ find my/folder -name fo*.txt
my/folder/foo.txt
$ find my/folder -name *fo*.txt
my/folder/foo.txt
$ find my/folder -name '*fo*.txt'
my/folder/foo.txt
$
I maintain that if OP wanted useful advice he should have demonstrated stuff like the outputs of his find commands and of `ls foo*.txt` and `ls /my/folder/foo*.txt`. I am getting tired of giving this advice here.
Stroller.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] Search filesystem with a wildcard
2011-02-27 6:52 ` Stroller
@ 2011-02-27 11:29 ` Willie Wong
0 siblings, 0 replies; 16+ messages in thread
From: Willie Wong @ 2011-02-27 11:29 UTC (permalink / raw
To: gentoo-user
On Sun, Feb 27, 2011 at 06:52:36AM +0000, Stroller wrote:
> AIUI using `find /my/folder -name foo*.txt` (i.e. unquoted) the shell will pass the * to find if it can't expand it itself.
Not necessarily true.
On bash if you set the 'nullglob' option, if the shell can't find the
file the word will be removed. If you set the 'failglob' character,
the command will quit with an error if the shell can't complete the
path expansion.
I expect there to be similar options in other shells.
W
--
Willie W. Wong wwong@math.princeton.edu
Data aequatione quotcunque fluentes quantitae involvente fluxiones invenire
et vice versa ~~~ I. Newton
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] Search filesystem with a wildcard
2011-02-27 3:46 ` Stroller
[not found] ` <73cb39da-826b-4754-91f4-40e9656fe961@ZABRYSVISEXHUB2.af.didata.local>
@ 2011-02-27 19:32 ` Grant
1 sibling, 0 replies; 16+ messages in thread
From: Grant @ 2011-02-27 19:32 UTC (permalink / raw
To: gentoo-user
>> I can't get find to work. This works:
>>
>> locate *foo*.txt
>>
>> but none of these work:
>>
>> find /my/folder -name foo*.txt
>> find /my/folder -name *foo*.txt
>> find /my/folder -type f -name '*foo*.txt'
>
> $ mkdir -p /my/folder
> mkdir: cannot create directory `/my': Permission denied
> $ mkdir -p my/folder
> $ touch my/folder/foo.txt
> $ find my/folder -type f -name '*foo*.txt'
> my/folder/foo.txt
> $ find /my/folder -name foo*.txt
> find: `/my/folder': No such file or directory
> $ ^/^
> find my/folder -name foo*.txt
> my/folder/foo.txt
> $
>
>> What am I doing wrong? I do need the find to be recursive in that folder.
>
> IMO the first thing you're doing wrong is concealing from us what you're actually doing.
>
> You're telling us that `find /my/folder -name foo*.txt` and two other versions don't work, yet you're relying on us taking your word on it that they don't.
>
> Prove it!
>
> You could have done exactly as I did above and create a folder called "my/folder" and created a file called foo.txt and then copied and pasted from the terminal to show us your actual commands.
>
> So we are only left to guess that the file you're looking for is NOT actually called "foo.txt" and it's NOT actually in a folder called "/my/folder". So the problem could be that you're looking for a file with a capital letter in its name, and that you're using "-name" instead of "-iname", or it could be that you're searching the wrong directory tree, or it could be a bunch of other things. Permissions springs to mind.
>
Yes, if I had posted the real stuff you would have been able to tell
me to use -wholename instead of -name to mimic mlocate functionality.
> But you'd rather waste our time in trying to conceal what you're looking for (I can only assume the file is called "Busty big sluts 3.avi") than help us help you.
>
I don't lose track of my Busty big sluts 3 AVI thank you very much.
- Grant
> Stroller.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] Search filesystem with a wildcard
2011-02-26 2:26 [gentoo-user] Search filesystem with a wildcard Grant
2011-02-26 3:19 ` Amankwah
@ 2011-02-26 3:23 ` Mike Gilbert
2011-02-26 17:16 ` Grant
1 sibling, 1 reply; 16+ messages in thread
From: Mike Gilbert @ 2011-02-26 3:23 UTC (permalink / raw
To: gentoo-user; +Cc: Grant
On Fri, Feb 25, 2011 at 9:26 PM, Grant <emailgrant@gmail.com> wrote:
> I used to use slocate like this to search the filesystem for a file:
>
> foo*.txt
>
> but mlocate doesn't seem to accept wildcards. I tried to figure out
> how to do it with find but failed. Can anyone point me in the right
> direction?
>
> - Grant
>
>
Try locate "*/foo*.txt". mlocate seems to match based on the full path name.
Also, to quote the manpage:
If any PATTERN contains no globbing characters, locate behaves as if
the pattern were *PATTERN*.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] Search filesystem with a wildcard
2011-02-26 3:23 ` Mike Gilbert
@ 2011-02-26 17:16 ` Grant
2011-03-01 0:58 ` Grant
0 siblings, 1 reply; 16+ messages in thread
From: Grant @ 2011-02-26 17:16 UTC (permalink / raw
To: Gentoo mailing list
>> I used to use slocate like this to search the filesystem for a file:
>>
>> foo*.txt
>>
>> but mlocate doesn't seem to accept wildcards. I tried to figure out
>> how to do it with find but failed. Can anyone point me in the right
>> direction?
>>
>> - Grant
>>
>>
>
> Try locate "*/foo*.txt". mlocate seems to match based on the full path name.
>
> Also, to quote the manpage:
>
> If any PATTERN contains no globbing characters, locate behaves as if
> the pattern were *PATTERN*.
I get it now, thank you for that.
- Grant
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] Search filesystem with a wildcard
2011-02-26 17:16 ` Grant
@ 2011-03-01 0:58 ` Grant
2011-03-01 2:11 ` Alex Schuster
0 siblings, 1 reply; 16+ messages in thread
From: Grant @ 2011-03-01 0:58 UTC (permalink / raw
To: Gentoo mailing list
>>> I used to use slocate like this to search the filesystem for a file:
>>>
>>> foo*.txt
>>>
>>> but mlocate doesn't seem to accept wildcards. I tried to figure out
>>> how to do it with find but failed. Can anyone point me in the right
>>> direction?
>>>
>>> - Grant
>>>
>>>
>>
>> Try locate "*/foo*.txt". mlocate seems to match based on the full path name.
>>
>> Also, to quote the manpage:
>>
>> If any PATTERN contains no globbing characters, locate behaves as if
>> the pattern were *PATTERN*.
>
> I get it now, thank you for that.
>
> - Grant
I'm having trouble with this again. I get:
# ls -l /var/cache/revdep-rebuild
total 424
-rwx------ 1 root portage 699 Feb 28 16:52 0_env.rr
-rwx------ 1 root portage 323445 Feb 28 16:38 1_files.rr
-rwx------ 1 root portage 34387 Feb 28 16:38 2_ldpath.rr
-rwx------ 1 root portage 57 Feb 28 16:40 3_broken.rr
-rwx------ 1 root portage 34641 Feb 28 16:39 3_errors.rr
-rwx------ 1 root portage 19 Feb 28 16:40 4_ebuilds.rr
-rwx------ 1 root portage 79 Feb 28 16:40 4_owners.rr
-rwx------ 1 root portage 23 Feb 28 16:40 4_pkgs.rr
-rwx------ 1 root portage 23 Feb 28 16:40 4_raw.rr
-rwx------ 1 root portage 25 Feb 28 16:40 5_order.rr
-rwx------ 1 root portage 2 Feb 28 16:52 6_status.rr
# locate *.rr
#
- Grant
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] Search filesystem with a wildcard
2011-03-01 0:58 ` Grant
@ 2011-03-01 2:11 ` Alex Schuster
2011-03-01 17:56 ` Grant
0 siblings, 1 reply; 16+ messages in thread
From: Alex Schuster @ 2011-03-01 2:11 UTC (permalink / raw
To: gentoo-user
Grant writes:
> I'm having trouble with this again. I get:
>
> # ls -l /var/cache/revdep-rebuild
> total 424
> -rwx------ 1 root portage 699 Feb 28 16:52 0_env.rr
> -rwx------ 1 root portage 323445 Feb 28 16:38 1_files.rr
> -rwx------ 1 root portage 34387 Feb 28 16:38 2_ldpath.rr
> -rwx------ 1 root portage 57 Feb 28 16:40 3_broken.rr
> -rwx------ 1 root portage 34641 Feb 28 16:39 3_errors.rr
> -rwx------ 1 root portage 19 Feb 28 16:40 4_ebuilds.rr
> -rwx------ 1 root portage 79 Feb 28 16:40 4_owners.rr
> -rwx------ 1 root portage 23 Feb 28 16:40 4_pkgs.rr
> -rwx------ 1 root portage 23 Feb 28 16:40 4_raw.rr
> -rwx------ 1 root portage 25 Feb 28 16:40 5_order.rr
> -rwx------ 1 root portage 2 Feb 28 16:52 6_status.rr
> # locate *.rr
> #
Check the the PRUNEPATHS setting in /etc/updatedb.conf. I have
/var/cache in it, but I'm not sure if this was the default, or it I did
change this myself. The other explanation would be that there is a file
matching *.rr in the current directory.
Wonko
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] Search filesystem with a wildcard
2011-03-01 2:11 ` Alex Schuster
@ 2011-03-01 17:56 ` Grant
0 siblings, 0 replies; 16+ messages in thread
From: Grant @ 2011-03-01 17:56 UTC (permalink / raw
To: gentoo-user
>> I'm having trouble with this again. I get:
>>
>> # ls -l /var/cache/revdep-rebuild
>> total 424
>> -rwx------ 1 root portage 699 Feb 28 16:52 0_env.rr
>> -rwx------ 1 root portage 323445 Feb 28 16:38 1_files.rr
>> -rwx------ 1 root portage 34387 Feb 28 16:38 2_ldpath.rr
>> -rwx------ 1 root portage 57 Feb 28 16:40 3_broken.rr
>> -rwx------ 1 root portage 34641 Feb 28 16:39 3_errors.rr
>> -rwx------ 1 root portage 19 Feb 28 16:40 4_ebuilds.rr
>> -rwx------ 1 root portage 79 Feb 28 16:40 4_owners.rr
>> -rwx------ 1 root portage 23 Feb 28 16:40 4_pkgs.rr
>> -rwx------ 1 root portage 23 Feb 28 16:40 4_raw.rr
>> -rwx------ 1 root portage 25 Feb 28 16:40 5_order.rr
>> -rwx------ 1 root portage 2 Feb 28 16:52 6_status.rr
>> # locate *.rr
>> #
>
> Check the the PRUNEPATHS setting in /etc/updatedb.conf. I have
> /var/cache in it, but I'm not sure if this was the default, or it I did
> change this myself. The other explanation would be that there is a file
> matching *.rr in the current directory.
>
> Wonko
You're right, it's in there by default. Thank you.
- Grant
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2011-03-01 17:58 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-26 2:26 [gentoo-user] Search filesystem with a wildcard Grant
2011-02-26 3:19 ` Amankwah
2011-02-26 4:33 ` Mike Gilbert
2011-02-26 10:24 ` Roman Zilka
2011-02-26 17:33 ` Grant
2011-02-26 18:26 ` luis jure
2011-02-26 21:45 ` Roman Zilka
2011-02-27 3:46 ` Stroller
[not found] ` <73cb39da-826b-4754-91f4-40e9656fe961@ZABRYSVISEXHUB2.af.didata.local>
2011-02-27 6:52 ` Stroller
2011-02-27 11:29 ` Willie Wong
2011-02-27 19:32 ` Grant
2011-02-26 3:23 ` Mike Gilbert
2011-02-26 17:16 ` Grant
2011-03-01 0:58 ` Grant
2011-03-01 2:11 ` Alex Schuster
2011-03-01 17:56 ` Grant
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox