Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to use this command to find some files.

share|improve this question
    
Which shell are you using? bash, tcsh, ?? –  Levon Jun 24 '12 at 22:09
8  
This is getting ridiculous; you just read the man page –  Michael Mrozek Jun 24 '12 at 22:36
add comment

closed as not a real question by Michael Mrozek Jun 24 '12 at 22:36

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 2 down vote accepted

It's simply

locate some_file

If you are going to use wildcards you must enclose the name in quotes. E.g. to find all .jpg files:

locate "*.jpg"

(@UlrichDangel was kind enough to clear this up for me)

For more information consult the locate man page.

share|improve this answer
    
if you are using locate *.jpg in bash - bash will try to expand *.jpg before executing locate. If you have files matching your parameter locate will get the matched filenames and not *.jpg. You should always quote, even with bash. –  Ulrich Dangel Jun 24 '12 at 23:56
    
No. If you have a file named 1.jpg in your current directory and run locate *.jpg (without quoting) the executed command will be locate 1.jpg so it will look for all files named 1.jpg. But the implementation of locate may do something special if you specify an existing file. BUT the takeaway is you also have to quote with bash. We should chat if you have any more questions –  Ulrich Dangel Jun 25 '12 at 0:09
    
@UlrichDangel Never mind .. I got it! Your last comment using 1.jpg was very clear .. never thought about the shell expanding this in that way. Thanks again! –  Levon Jun 25 '12 at 0:14
    
there is also mlocate .. etc en.wikipedia.org/wiki/Locate_(Unix) –  Xsi Nov 23 '12 at 16:39
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.