Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sorry, this question is going to be total newb factor. How do I search within a particular directory using the locate command?

The following command isn't working for me:

# locate -i mnt/external/Songs/"tangerine"

I would like to search within the "Songs" folder.

share|improve this question
Besides the answer @enzotib gave you can also grep the output from locate: locate tangerine | grep mnt/external/Songs * if you want to look for tangerine that includes mnt/external/Songs – Rinzwind Sep 14 '11 at 11:10
up vote 5 down vote accepted

Maybe you want

locate -ir 'mnt/external/Songs/.*tangerine'

-r is for regular expressions search, like in grep. You may also use plain globs for situations as simple as this:

locate /mnt/external/Songs/*tangerine*
share|improve this answer
Thank you enzo. I prefer the second line of code you provided because I can autocomplete with tab – user784637 Sep 16 '11 at 2:23

Give the find command a try

find /mnt/external/Songs/ -iname tangerine*

Example: I wanted to search for songs with the word concerto in their filename in my Music folder, so :

  nits@nits-workstation:~$ find /mnt/Storage_1/Music/ -iname *concerto*


/mnt/Storage_1/Music/Music I/Antonio Vivaldi - The Four Seasons and Violin Concertos
/mnt/Storage_1/Music/Music I/Antonio Vivaldi - The Four Seasons and Violin Concertos/10. Concerto No. 4 In F Minor, Rv 297 'winter' - I Allegro Non Molto.mp3
/mnt/Storage_1/Music/Music I/Antonio Vivaldi - The Four Seasons and Violin Concertos/01. Concerto No. 1 In E, Rv 269 'spring' - I Allegro.mp3

This is a nice tutorial for the find command.

share|improve this answer
Is there any way we can do this with locate? Find is super slow on my external =( – user784637 Sep 14 '11 at 11:03
This article is good too! – user784637 Sep 14 '11 at 11:04
@LedZeppelin: Agreed , community documentation is the best. For the locate command look at entozib's answer below. – Nitin Venkatesh Sep 14 '11 at 11:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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