Tim Peeler on Mon, 17 Jan 2000 01:56:30 -0500 (EST) |
On Sun, 16 Jan 2000, you wrote: > > > 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 Hey, cool. I learn something new every day :-) ______________________________________________________________________ Philadelphia Linux Users Group - http://plug.nothinbut.net Announcements - http://lists.nothinbut.net/mail/listinfo/plug-announce General Discussion - http://lists.nothinbut.net/mail/listinfo/plug
|
|