Okay, so I'm learning Bash, and there's that exercise;
"Write a script that checks every ten seconds if the user 'user000' is logged in."
My idea is to grep a who, but I don't know how to incorporate this into a script. I tried things like
if [ `who | grep "user000"` ] then things
but it returns the matched lines with grep, not true/false.
You want grep -q. That's "quiet mode"; just sets status based on whether there were any matches, doesn't output anything. So:
if who | grep -q "user000"; then things; fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With