Michael C. Toren on Sun, 16 Jan 2000 15:51:51 -0500 (EST) |
> > I was thinking of just using the command id, but for either grep or id, > > how do I make a variable equal to true or false depending on what grep or > > another command returns? (in bash) > > Just use an if statement. > > if (grep regexp foo 1>&2 > /dev/null) ; then Rather than redirecting stderr and stdout to /dev/null, you could grep's --silent or -q option, which suppresses normal matching output. It also optimizes things a bit, by exiting after finding the first match. Additionally, you don't need to enclose the if condition in parentheses with the Bourne shell. (Doing so just causes your shell to fork an additional time). -mct
|
|