5
rated 0 times
[
5]
[
0]
/ answers: 1 / hits: 5034
/ 2 Years ago, mon, february 21, 2022, 9:43:21
I have the following script that should exist if the user does not exist.
#check if user currently exists on system
if id $User > /dev/null 2>&1
then
#user exists no need to exit program
echo "blah blah, what a waste of space"
else
echo "This user does NOT exists. Please create that user before using this script.
"
exit
fi
My problem is that I would ideally like to place a "not" if that first if statement so that I can trim down my if, else statement. Ideally I would like something like this:
if !(id $User > /dev/null 2>&1)
then
echo "This user does NOT exists. Please create that user before using this script.
"
exit
fi
More From » bash