On Wed, 17 Jul 2002 at 5:38pm (-0700), David Busby wrote:
> How would I construct the "if" to see if a module is loaded
>
> I've tried
>
> if [ -n "lsmod |grep $module" ]
> as well as
> if [ -z "lsmod |grep $module" ]
>
The main problem with your code is that bash doens't know the stuff in the
"'s is a command to be executed. Try something like.
if [ -n "$(lsmod | grep $module)" ]; then
echo "Yeah.. that puppy is loaded...."
stuff
fi
... or more simply...
[ -n "$(lsmod | grep $module)" ] && {
echo "Yeah.. that puppy is loaded...."
stuff
}
... or just use the exit code directly and...
lsmod | grep -q $module && {
echo "Yeah.. that puppy is loaded...."
stuff
}
... ahh.. ain't shell grand. ;)
M.
--
WebCentral Pty Ltd Australia's #1 Internet Web Hosting Company
Level 5, 100 Wickham St. Network Operations - Systems Engineer
PO Box 930, Fortitude Valley. phone: +61 7 3249 2557
Queensland, Australia 4006. pgp key id: 0x900E515F
_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list