Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 use backtrack and I have a Packages.gz file with some packages on my hard drive. I want to use "apt-cache search" to search only the folder which contain Packages.gz. Is this possible?

share|improve this question

You're looking for grep-dctrl which is part of the dctrl-tools package.

For example:

$ grep-dctrl -ns Package -F Filename mplayer2_2.0~git20120817-dmo1_amd64.deb www.deb-multimedia.org_dists_wheezy_main_binary-amd64_Packages 

-n means to only print the value of the fields, not the label. -s Package means to only print the Package field. -F Filename means to only search the filename field. mplayer2…deb is what to search for. www…_Packages is the file to search.

I'm not sure if it'll search a .gz file directly, but it will search stdin, so you can just use a pipe: zcat Packages.gz | grep-dctrl …

edit: Given you have the actual .deb, not just the file name, you can also use dpkg-deb to get the info. Here is an example with wireshark:

$ dpkg-deb --showformat='${package}\n' -W a.deb

and, to explain --showformat lets you format the output (here, getting just the package name, instead of package and version, which is the default); -W says to print formatted info about a binary package. a.deb is of course the .deb package to print info about (I renamed it to show that it isn't just spitting back out the filename).

share|improve this answer

Why use apt-cache? zgrep will do for searching in a single file...

share|improve this answer
the thing is I want to find out a package name (e.g. "adobereader-enu" for "AdbeRdr9.5.4-1_i386linux_enu.deb" file). or maybe there is another way than using "apt-cache"? – ngwdaniel Mar 26 '13 at 15:58
zgrep -i 'ad.?be; /path/to/packages.gz – Dennis Kaarsemaker Mar 26 '13 at 16:05

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.