Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

2 Answers

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 
mplayer2

-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
wireshark

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
add comment

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
add comment

Your Answer

 
discard

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.