4 ms·
Interesting stuff. One small correction that I noticed: $ sudo locate cfg | grep \.cfg$ should contain quotes, like this: $ sudo locate cfg | grep '\.c
by bxparks 5y ago
Interesting stuff. One small correction that I noticed:
$ sudo locate cfg | grep \.cfg$
should contain quotes, like this:
$ sudo locate cfg | grep '\.cfg$'
because the shell swallows the backslash.
But locate(1) supports globs, so I think this could be simplified to just:
$ sudo locate '*.cfg'
But on my Ubuntu, /etc/updatedb.conf has PRUNE_BIND_MOUNTS="yes", so my /home, on a separate partition, does not get updated. So I often resort to:
$ find -name '*.cfg'
somewhere in my $HOME directory.
- nuxi 5y agoYou can create a separate locate database for /home if you want. Set it up for periodic updates (via cron or other means) and then use "locate -d <path_to_db>" for searching.
- revscat 5y agoOr using globbing in zsh: $ echo **/*.cfg You can even order my most recently modified: $ echo **/*.cfg(om) `setopt EXTENDED_GLOB` needs to be on.
- twic 5y agoYou might want to add -b: -b, --basename Match only the base name against the specified patterns. This is the opposite of --wholename. To ignore files which have .cfg somewhere in their path, but aren't called .cfg. Or you might not!