I have been using find command to find files on my 1 tb hard disk. it takes very long. then I used locate which proved to be faster with regular update using updatedb. But the limitation of locate is that I cannot find files with certain size or modified/created time. can you suggest me any ideas on how to find files at more speed or in that case how to pipe output of locate command in a way that all other information like size, time, etc. can be displayed or redirected to a file.
|
I haven't seen an answer that comes near the wishes of Chaitanya. If you want to search on filename, a combination of locate, find, ls and grep could be sufficient. But I think Chaitanya want to search for example for 'all files created before 2011'. This can perfectly done with find, but I can imagine it will take a long time searching through 1TB (depends more on the amount of files, not necessarily the total size). To speed this up I think indexing is inevitable. The problem of locate (indexing with updatedb) is that it doesn't index creation time. So what Chaitanya need is something that indexes the needed attributes of files (file name, file size, creation date, more?). And later something that can search on these attributes. As far as I know there is no out-of-the-box solution for this on Ubuntu. An important comment of Chaitanya: "Now the thing is that I am designing a php based web gui...". Because your problem sounds quite specific, maybe you want to build somehting yourself. Some suggestions:
|
|||
|
|
|
You can try Tracker. It has a daemon that waits for file changes and updates a database with all the metadata as possible, and a client that you can use to search for files. Note that it only indexes the user dir, not all the hard disk. The main dawback is that it needs CPU time to index, so use it only if your computer has power to spare. You will need to install both the server and client, they are named tracker and tracker-gui. If you search for tracker in the Software Center they are the two first matches. If you prefer to install them from the command line:
|
|||
|
|
Response to comment:
produces: -rw-rw-r-- 1 user group 4075134 2012-03-30 22:37 /home/user/Music/Star Wars: Episode 1 - Duel of Fates (Darth Maul's Theme).mp3 Thx @Oli in AskUbuntu chat for tipping me off to "something" to get around shell escapes |
|||||
|
|
The issue with locate is that it only collects file information occasionally on a regular cron schedule. You if you need mlocate to update its information, just run this
If you need a solution that is more "real-time" and updates constantly, I would suggest going with something that is specifically designed to monitor your filesystem, like To redirect the output of
|
|||
|
|
|
Use "find option Parameter". See "man find" more detail. Use locate to find a document quickly and easily, eg. "locate *.jpg" |
||||
|
|
It provides
|
|||
|
|

findcommand including arguments which takes too long? Orfindis slow with any arguments for you? On my system find scans the whole filesystem within 2 seconds (100GB). – arrange Mar 12 '12 at 10:14findtakes several minutes to return on my media and image home server.root@viashivan:/media/data1# find . -type f | wc -land rhe result is 2044791. – gecko May 9 '12 at 0:25