Bash - Test for multiple users
- by Mike Purcell
I am trying to test if current user one of two allowed users to start a process, but I can't seem to get the multi-condition to work correctly:
test ($(whoami) != 'mpurcell' || $(whoami) != 'root')) && (echo "Cannot start script as non-ccast user..."; exit 1)
Is there a way to test multiple users without have to enter two lines, like this:
test $(whoami) != 'mpurcell' && (echo "Cannot start script as non-ccast user..."; exit 1)
test $(whoami) != 'root' && (echo "Cannot start script as non-ccast user..."; exit 1)