Thread: help with a script
i need implement in larger script of mine, bash code check if packages installed, if yes, something, if not else.
can give me example code of how should it?
you can use dpkg(1) test installed packages:
code:#!/bin/sh pkglist="dpkg foobar" pkg in $pkglist dpkg -l $pkg >/dev/null 2>/dev/null if [ $? -eq 0 ]; echo "package $pkg installed" else echo "package $pkg not installed" fi donecode:$ ./pkgtest.sh package dpkg installed package foobar not installed
Forum The Ubuntu Forum Community Ubuntu Official Flavours Support New to Ubuntu [ubuntu] help with a script
Ubuntu
Comments
Post a Comment