LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-23-2016, 11:12 PM   #1
fanoflq
Member
 
Registered: Nov 2015
Posts: 281

Rep: Reputation: Disabled
updatedb not working correctly?


I could not locate a file, part3.txt, since it was just created.
I tried this with update.

updatedb: can not open a temporary file for `/var/lib/mlocate/mlocate.db'

~/test $ sudo updatedb

~/test $ ls dir2
part3.txt

~/test $ ls part?.txt
part1.txt part2.txt

~/test $ locate part?.txt
/home/user/test/part1.txt
/home/user/test/part2.txt

Now, why is file, /home/user/test/dir2/part3.txt,
missing from locate's result since I just ran updatedb?

Last edited by fanoflq; 01-24-2016 at 01:05 AM.
 
Old 01-24-2016, 03:17 PM   #2
Alpha90
Member
 
Registered: Jul 2012
Posts: 93

Rep: Reputation: Disabled
The issue is that the wild card expansion. Essentially what is happening is your telling locate to look for part1.txt and part2.txt . Basically if you were to say go to / and try that you would get nothing returned because there would not be a part<something>.txt file in the root directory for it to expand and search for.
 
Old 01-24-2016, 03:57 PM   #3
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 2,517
Blog Entries: 1

Rep: Reputation: 494Reputation: 494Reputation: 494Reputation: 494Reputation: 494
Probably wild card expansion as previously mentioned. It's not behaving as expected because it finds matches in your current directory. Try wrapping the search term with ''.

$ locate 'part?.txt'

or try using the -- to override the wild card substitution. As in override the interpretation of the wildcard by the shell before passing the parameter(s) to the application.

$ locate -- part?.txt
 
Old 01-24-2016, 04:16 PM   #4
fanoflq
Member
 
Registered: Nov 2015
Posts: 281

Original Poster
Rep: Reputation: Disabled
Alpha90 >> Basically if you were to say go to / and try that you would get nothing returned because there would not be a part<something>.txt file in the root directory for it to expand and search for.

dir2 is a sub directory of test.
And part3.txt is in ~/test/dir2/part3/txt.
Why are you referring to / ?
I am not following.

Shadow7 :
I tried your suggestions. Did not work.

Here are all the files:
~ $ find ./test -name part?.t?t
./test/part1.txt
./test/dir/part4.txt
./test/dir2/part3.txt
./test/part2.txt

As you can see, find command found all the files.

How to I tell locate to search all the path for the file?
 
Old 01-24-2016, 04:23 PM   #5
fanoflq
Member
 
Registered: Nov 2015
Posts: 281

Original Poster
Rep: Reputation: Disabled
Found solution:

Use option -b, --basename
Match only the base name against the specified patterns. This is the opposite of --wholename.


~ $ locate -b part?.t?t
/home/user/test/part1.txt
/home/user/test/part2.txt
/home/user/test/dir2/part3.txt

Now I added part4.txt today. So it is not in updatedb yet.
Run updatedb to update mlocate

sudo updatedb
[sudo] password for foffb:
~ $ locate -b part?.t?t
/home/user/test/part1.txt
/home/user/test/part2.txt
/home/user/test/dir/part4.txt
/home/user/test/dir2/part3.txt


/home/user/test/dir/part4.txt is found!

Last edited by fanoflq; 01-24-2016 at 04:27 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] updatedb not working ! nkd Ubuntu 2 03-20-2011 03:14 PM
updatedb crashes: src/updatedb.c:730: scan_cwd: Assertion `name_size > 1' failed sumanc Fedora 3 07-11-2008 05:39 PM
What's the difference between 'updatedb' and 'updatedb&' ?? DreameR-X Linux - Newbie 4 12-18-2004 05:36 PM
swaret help- updatedb not working ajbrouwe Slackware 4 12-18-2004 02:36 PM
Mozilla isn't working after updatedb justinian1978 Fedora 6 04-12-2004 07:37 AM


All times are GMT -5. The time now is 09:26 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration