[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lazy man's "pkg_delete" (terrible script - help!)
- To: misc_(_at_)_openbsd_(_dot_)_org
- Subject: lazy man's "pkg_delete" (terrible script - help!)
- From: poff_(_at_)_sixbit_(_dot_)_org
- Date: Mon, 30 Dec 2002 22:55:12 +0100 (CET)
Hi,
I was a bit shocked to find pkg_delete xm* wouldn't work, and that one has
to type in the full name and version of the file, or I'm missing
something...
So I whipped togetherthis dreadful script (shame!) and was wondering if
someone could improve it for me? I new to shell scripting...
# cat /usr/local/bin/pkgdelete
#!/usr/local/bin/bash
if [ ! $1 ]; then
echo "please enter partial package name"
else
match=`pkg_info | awk '{print $1}' | grep $1`
matches=`echo $match | wc -w | sed -e "s/[ ]*[ ]*//"`
if [ ! $match ]; then
echo "no matching packages found"
else
if [ $matches != "1" ]; then
echo "too many ($matches) matches:"
echo $match
echo "please specify"
else
echo "$match getting removed"
echo `pkg_delete $match`
if [ ! `pkg_info | grep $match` ]; then
echo "job done!"
else
echo "errors... please see above :("
fi
fi
fi
fi
#
Well it works ok but it's pretty disgusting you'll agree!
poff_(_at_)_sixbit_(_dot_)_org
SDF Public Access UNIX System - http://sdf.lonestar.org
Visit your host, monkey.org