LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   who command (https://www.linuxquestions.org/questions/linux-newbie-8/who-command-538389/)

dory550 03-17-2007 08:03 PM

who command
 
Hi guys

What Bash script do I use to test the true of false results of the command 'who | grep pts'
how do I assign the results to a variable?
Thank you
Dory

Tinkster 03-17-2007 08:27 PM

Hi, and welcome to LQ!


The result is in $?

Code:

who | grep pts > /dev/null 2>&1
result = $?


Cheers,
Tink

dory550 03-18-2007 03:41 AM

Tink
echo $? produces 1 or 0

result = $? #produces an error( -bash: results: command not found )

thanks
Dory

Tinkster 03-18-2007 12:42 PM

Sorry about that; give the spaces around the = a miss.
And yes, 0 is success, 1 is failure.


Cheers,
Tink

dory550 03-20-2007 08:06 PM

Tink
Thank you for your help
Dory

Tinkster 03-21-2007 12:46 AM

You're welcome, glad it works for you.


Cheers,
Tink


All times are GMT -5. The time now is 01:50 PM.