Cadged this from someone else and tweaked it a bit.
#!/bin/bash # ~/bin/searchrepo.sh cd /var/lib/apt/lists/ cat *$1* | grep "^Package: " | sed 's/^Package: //' | sort -u
Usage - "searchrepo.sh string"
Example - "searchrepo.sh multimedia" - prints all packages contained in repos with string "multimedia" in their name.
Useful with output piped thru grep to search for specific packages.
Last edited by spoovy (2011-01-24 01:10:50)
Is this better than using Synaptic or apt-cache to search for packages?
I never found a way with aptitude, so I use this. There might be a way with apt-cache i dunno i never thought to look to be honest. Never use synaptic.
Is there a way with apt-cache?
Last edited by spoovy (2011-01-24 00:34:37)
sudo apt-cache search multimedia
That just searches for packages containing the string "multimedia", in all enabled repos. As in, it returns packages from all enabled repos.
My script returns only results from the specified repo.
Last edited by spoovy (2011-01-24 00:47:32)
@spoovy - using your script how or where would you specify the repo you wanted to search?
It's explained in the OP. The example searches the debian multimedia repo, as it's the only repo in my sources.list with "multimedia" in the title.
You could use it to search any repo by specifying any string unique to that repo. I run debian with the statler repo added post install, so I also use it to see what's available in the statler repo with "searchrepo.sh statler".
Ok I understand now. For some reason I was thinking the string was the package name not repo name.
I tried to get it to work passing a second argument to grep but I haven't figured it yet. Any ideas?
It would need to return all results in the absence of a second argument, or only those results matching the second argument if one is present.
| grep "$2" doesn't work.