find whether a library is installed using shell script

deb, linux, shell

Solution

What I want is to determine the library/package is currently installed or not in system

`dpkg -s` does not require root permission, and will display package status details.

Example shell script:

#!/bin/sh

for P; do
    dpkg -s "$P" >/dev/null 2>&1 && {
        echo "$P is installed."
    } || {
        echo "$P is not installed."
    }
done

Usage is:

`script.sh package1 package2 .... packageN`

Problem

I'm complete noobs in shell script what i want is shell script that determine a list of library/package currently installed if not install them without user permission What I want is to determine the library/package is currently installed or not in system I'm aware of aptitude search command but I looking for a better solution e.g I have define(in shell script) check for readline library/package now how can I from inside the shell script (I want to create) know that readline package is currently installed or not. Any idea or suggestion would certainly help

Original source