dlocate is a fast alternative to dpkg for queries like `dpkg -L' and `dpkg -S'
Note that dlocate uses GNU grep, so normal regexp metacharacters need to be taken into account or avoided by using the '-F' (Fixed String) grep option.
For example, to search for `/usr/bin/[', you might try: dlocate '/usr/bin/\[' or dlocate -F '/usr/bin/['
Note that dlocate uses GNU grep, so normal regexp metacharacters need to be taken into account. Fixed String searches are incompatible with -S.
For example, to search for `/usr/bin/[', you need to type:
dlocate '/usr/bin/\['
Internally this uses grep on a file containing the reformatted output of 'dpkg -l' (four fields separated by tabs; status, package-name, installed version, short description) so it will return packages whose version or short description matches, too.
Various flavours of regular expression are supported. For example, Extended Regexp:
dlocate -l '^..[[:space:]]libc6'
or Perl Regexp:
dlocate -P -l '^..\slibc6'
Both of these will list all the packages whose names start with `libc6'.
Note that because of the difference between regular expressions and dpkg's shell-style pattern matching, the output from dlocate -l is occasionally different to the output from dpkg -l.
This is not a bug, regular expressions are far more flexible than shell pattern matching. This is the way dlocate is supposed to run, but it may require some knowledge of regular expressions to get the output you want.
See update-dlocatedb(8) for details.
To view all man pages contained within the dpkg package:
man $(dlocate -man dpkg)
To purge kernel version 2.6.28.7 and all related module packages:
dlocate -k | grep -- -2.6.28.7 | xargs apt-get purge
To check the md5sums of the dlocate package:
dlocate --md5check dlocate
To use dpkg-repack to make a backup copy of all installed mythtv packages just before
upgrading them:
dlocate -l mythtv | awk '/^.i/ {print $2}' | xargs dpkg-repack
# dlocate -l mythtv | awk '/^.i/ {print $2}' | xargs dpkg-repack
dpkg-deb: building package `libmythtv-perl' in `./libmythtv-perl_0.21.svn20090414-0.0_amd64.deb'.
dpkg-deb: building package `mythtv' in `./mythtv_0.21.svn20090414-0.0_amd64.deb'.
dpkg-deb: building package `mythtv-backend' in `./mythtv-backend_0.21.svn20090414-0.0_amd64.deb'.
dpkg-deb: building package `mythtv-common' in `./mythtv-common_0.21.svn20090414-0.0_amd64.deb'.
dpkg-deb: building package `mythtv-database' in `./mythtv-database_0.21.svn20090414-0.0_amd64.deb'.
dpkg-deb: building package `mythtv-doc' in `./mythtv-doc_0.21.svn20090414-0.0_amd64.deb'.
dpkg-deb: building package `mythtv-frontend' in `./mythtv-frontend_0.21.svn20090414-0.0_amd64.deb'.
dpkg-deb: building package `mythtv-perl' in `./mythtv-perl_0.21.svn20090414-0.0_amd64.deb'.
dpkg-deb: building package `mythtv-status' in `./mythtv-status_0.9.0-5_amd64.deb'.
dpkg-deb: building package `mythtv-themes' in `./mythtv-themes_0.21-0.0_amd64.deb'.
dpkg-deb: building package `mythtvfs' in `./mythtvfs_0.5.2-2_amd64.deb'.
dpkg-deb: building package `python-mythtv' in `./python-mythtv_0.21.svn20090414-0.0_amd64.deb'.