How to check that if a package is installed?

Smoot Carl-Mitchell smoot at tic.com
Tue Nov 30 19:16:24 UTC 2010


On Tue, 2010-11-30 at 13:45 -0500, Boggess Rod wrote:
> Date: Tue, 30 Nov 2010 09:15:15 -0500
> From: Hal Burgiss <hal at burgiss.net>
> Subject: Re: How to check that if a package is installed?
> To: "Ubuntu user technical support,	not for general discussions"
> 	<ubuntu-users at lists.ubuntu.com>
> Message-ID:
> 	<AANLkTi=Yy4OcXjto+n=s0hfZYO1Z+=xFPP96mgpUfyUN at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> On Tue, Nov 30, 2010 at 7:54 AM, S Mathias <smathias1972 at yahoo.com>
> wrote:
> 
> > if [ "$(dpkg -l | awk '/tofrodos/ && /^ii/ {print $2}' | awk
> > '/^tofrodos/')" == "" ]; then echo -e "error: no zip package
> > detected\!\n\nYou could install it like e.g.: \"apt-get install
> tofrodos\"";
> > fi
> >
> > Is there a better way then this?
> >
> >
> Seems kind of wordy to me for what it really does ...
> 
> dpkg -l |grep torfrodos || echo nope

Even easier:

dpkg-query --show --showformat '${Package}\n'

This just gives you the names of the installed packages.

See the dpkg-query man page for the format details.

-- 
Smoot Carl-Mitchell
System/Network Architect
voice: +1 480 922-7313
cell: +1 602 421-9005
smoot at tic.com





More information about the ubuntu-users mailing list