Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the name of a file and I need to determine what package provides it. If it weren't for the fact that I need to perform a case-insensitive search, the following command would work fine:

dpkg -S filename.txt

This works great if the file is named 'filename.txt' but not if it is named 'Filename.txt'.

Consulting the manpage for the dpkg command Manpage icon doesn't reveal anything about a case-insensitive option for the command and I'm left in the dark.

Is there a way to query the package database for a certain file in a case-insensitive manner?

share|improve this question
up vote 10 down vote accepted

dpkg accepts wildcard patterns. That's ok if you don't know whether the file name has an initial capital letter, but it doesn't scale.

dpkg -S '[Ff][Ii][Ll][Ee][Nn][Aa][Mm][Ee].[Tt][Xx][Tt]'

With no extra tools, you can easily reproduce what dpkg -S does internally:

grep -Fi filename.txt /var/lib/dpkg/info/*.list

You can use dlocate Install dlocate to speed up dpkg -S with an index (like locate speeds up find /, but you don't gain nearly as much with dlocate). Since dlocate is built on locate, it accepts the same options including -i for a case-insensitive search. Since dlocate uses an index (normally rebuilt every night), it might be slightly out of date.

dlocate -i filename.txt

apt-file Install apt-file searches a file name in all packages that are available for installations. It has a -ui option for a case-insensitive search.

apt-file -i search filename.txt
share|improve this answer
+1 for an accurate and comprehensive answer. Thank you! This was exactly the answer I was hoping for. – Nathan Osman Aug 21 '12 at 23:55
One quick question: does dlocate update the index when first installed? I will mostly be using the tool on a build farm where the command will likely run immediately after install. – Nathan Osman Aug 21 '12 at 23:56
@GeorgeEdison update-dlocatedb is called from the postinst, so yes. – Gilles Aug 22 '12 at 0:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.