3 ms·
How about: locate "pattern" | grep -v "antipattern" locate is installed by default on Ubuntu and I think on most Linux distributions so I'm not sure why you n
by tgflynn 11y ago
How about:
locate "pattern" | grep -v "antipattern"
locate is installed by default on Ubuntu and I think on most Linux distributions so I'm not sure why you need to worry about the cron jobs and all of those command line arguments, normally that's taken care of automatically (unless of course you have special requirements for when the cron job runs).
- brbsix 11y agoThe system `updatedb` job (that creates the database `locate` uses) only scans one root tree. This one root tree includes lots of random junk (basically your entire filesystem minus a few things) and does not support multiple filesystems/root trees. Hence the necessity to create multiple databases. I agree it's pretty silly.
- tgflynn 11y ago"does not support multiple filesystems/root trees." I just tried the experiment on Ubuntu 14.04 and that statement does not appear to be true. If I create a file on a mounted non-root filesystem then run updatedb followed by locate with a pattern matching that filename I get the file's path. There are a couple of things that could be preventing this in /etc/updatedb.conf. Make sure the mounted filesystem isn't excluded by PRUNEPATHS or PRUNEFS. Also I'm not clear on what PRUNE_BIND_MOUNTS does but my guess is that if set to yes it would exclude nfs mounted filesystems.
- brbsix 11y agoI was incorrect. It does support other mounted filesystems, just not multiple root trees. As you suspected, `updatedb.conf` had /media in PRUNEPATH.
- atmosx 11y ago^--- this is the standard solution. Supports regex, can count result no, limit, ignore and it's fast. Here: http://linux.die.net/man/1/locate http://linux.die.net/man/1/locate