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?

2 Answers 2


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).


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

  • 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"?
    – daniel
    Mar 26, 2013 at 15:58
  • zgrep -i 'ad.?be; /path/to/packages.gz Mar 26, 2013 at 16:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .