A subshell is spawn by using a ` ( the [~] key ) surrounding the desired command. To the best of my knowledge an "if" conditional test in a bash shell ( if ] then fi ) cannot drop into a subshell within the brackets []. However, two ways I know how to solve your question.
1) #!/bin/sh ... $VARIABLE_NAME="`lsmod |grep $module`" # Notice the "`", and the variable is surrounded by double quotes. # If the subshell command generates several lines, it does goofy things # to your terminal. Double quotes keep it contained. if [ -n/-z "$VARIABLE_NAME" ] # Double quotes again then do_stuff... fi 2) #!/bin/sh ... test -n/-z "`lsmod |grep $module`" ||/&& {do_stuff...} # Notice the "`" for the subshell command, and it is surrounded by double quotes # Pick either || or && to determine if the condition is met or not met and then "do_stuff". Finally, a subtle gotcha, a variable in single quotes will tell the shell to ignore the contents within, and double quotes will tell the shell to interpret within the quotes... For more info, from a bash shell command line: ]# help test ]# help if ]# help [ Hope this helps, Ken > Date: Wed, 17 Jul 2002 20:19:36 -0500 (CDT) > Subject: Re: Question on 'if' in bash script > > to access a command from within shell, enclose it in ` ` > as > for files in `cat some.list` > do > blah > etc.... > > On Wed, 17 Jul 2002, 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" ] > > > > I can't get either to work...what am I doing wrong? > > > > /b > > > > > > > _______________________________________________ Redhat-list mailing list [EMAIL PROTECTED] https://listman.redhat.com/mailman/listinfo/redhat-list