Topic: Quick package information
I use this every day, so someone might possibly find it useful...
aptitude show packagename
works well enough but on an oldish box it can be very slow. apt-cache and dpkg are much faster to show results, but apt-cache doesn't know if the package is installed on your machine or not, and dpkg only knows about stuff that is installed. Putting them together, you can do something like this (edited 2010/3/1):
#!/bin/bash
# get info about packages, installed or not
output=''
for i in "$@"
do
package=$( dpkg -s $i 2>/dev/null )
if grep 'Status: install ok installed' > /dev/null <<< "$package"
then package="$package
Commands:
$( dpkg -L $i | grep 'bin/' )"
else package="$i: NOT INSTALLED
"
package="$package$( apt-cache show $i 2>&1 )"
fi
output="$output$package
--------------------------------------
"
done
if [ -t 1 ]
then
echo "$output"
else
# echo "$output" | leafpad /dev/stdin
leafpad <(echo "$output")
# conky --config=$HOME/.conkyrc-message --text="$output"
fi
exitSave this as pkg.sh or something, put it in your ~/bin folder, or, better, link to it from there with a link called "pkg" so it's in your $PATH. Now you can call it with
pkg somepackage someotherpackageIt will do several packages at once. If you call it from a terminal you'll get the results there, if you call it from gmrun for example with alt+F2 (or from some other script?) it will pop up a leafpad window with the results in.
TO DO: it would be nice to have "package search" or something in Leafpad's title bar, if anyone knows how to do that...?
Last edited by johnraff (2010-03-01 06:13:31)
------------------------
( a boring Japan blog , and idle twitterings )
“There is more Unix-nature in one line of shell script than there is in ten thousand lines of C.” - Master Foo