LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-14-2014, 05:24 AM   #1
ddc
LQ Newbie
 
Registered: Jul 2014
Posts: 13

Rep: Reputation: Disabled
how to find folders only with locate command


Hi,

Tried with "locate -r "/home/username/.*/foldera$" -e -l 5" to find the foldera. It's failed. What am I missing here?

Working fine with "locate -r "/foldera$" -e -l 5". But, I want to find folder under home directory only.

How to list folderA also if exists in home directory. needs to consider case insensitive.

How to find only folders with locate command.

Thanks,
ddc

Last edited by ddc; 07-14-2014 at 06:25 AM.
 
Old 07-14-2014, 08:25 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,148

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
Why use locate?
Code:
find /home/username -type d
find /home/username -type d -iname foldera
 
1 members found this post helpful.
Old 07-14-2014, 08:53 AM   #3
ddc
LQ Newbie
 
Registered: Jul 2014
Posts: 13

Original Poster
Rep: Reputation: Disabled
find tool finds folder by looking into file system. I am looking for locate(mlocate.db) which is very fast.
 
Old 07-14-2014, 12:28 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
locate .skype
/home/jj/.config/google-chrome/Default/Local Storage/https_login.skype.com_0.localstorage
/home/jj/.config/google-chrome/Default/Local Storage/https_login.skype.com_0.localstorage-journal
/home/jj/.config/google-chrome/Default/databases/https_login.skype.com_0
/home/jj/.config/google-chrome/Default/databases/https_login.skype.com_0/1
vs.
Code:
locate .Skype
...
/home/jj/.Skype.last/my-kungfu/httpfe/cookies.dat
/home/jj/.Skype.last/my-kungfu/config.xml
/home/jj/.Skype.last/my-kungfu/config.lck
/home/jj/.Skype.last/shared.lck
Doesn't look like locate supports case-sensitivity.

Use find.
 
2 members found this post helpful.
Old 07-14-2014, 02:40 PM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by ddc View Post
Tried with "locate -r "/home/username/.*/foldera$" -e -l 5" to find the foldera. It's failed. What am I missing here?

Working fine with "locate -r "/foldera$" -e -l 5". But, I want to find folder under home directory only.
I can't see how the first could fail if the second succeeds. What about:
Code:
locate -r '.*/foldera$' -e -l 5
locate -r '/.*/foldera$' -e -l 5
locate -r 'username/.*/foldera$' -e -l 5
Quote:
Originally Posted by ddc
How to list folderA also if exists in home directory. needs to consider case insensitive.
Quote:
http://linux.die.net/man/1/locate

-i, --ignore-case
Ignore case distinctions when matching patterns.
 
3 members found this post helpful.
Old 07-14-2014, 02:59 PM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
or not.
 
Old 07-14-2014, 07:36 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,140

Rep: Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123
Note that patterns are handled differently for -r vs --regex if it contains globbing ...
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Find files on Linux with the command locate LXer Syndicated Linux News 0 07-13-2012 03:31 AM
[SOLVED] How to use find command to locate files linuxandtsm Linux - Newbie 4 03-30-2012 10:00 AM
difference between find and locate command sandeep002gupta Linux - Desktop 1 05-09-2011 04:16 AM
find -exec command to recursively delete files and folders in folders with X name Joan Murt Linux - Newbie 2 07-08-2009 04:35 PM
Wat is main difference between find and locate command. rktech83 Linux - General 1 03-08-2006 07:38 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration