Hi! When one types a user that doesnt exist it immediately goes to the else statement instead of into the if statement and prints user doesnt exist how do i change this? This is my function:
function viewUserProperties {
echo "Which user would you like to view?"
read user
if [[ $user == 0 ]];
then
echo "User does not exist!"
else
printf "\nUser view for $user\n"
printf "\n-15s\n %-15s\n %-15s\n %-15s\n
%-15s\n%-15s\n%-15s\n", "Username" "Password" "User ID" "Group ID" "Directory" "Shell"
getent passwd $user | tr ':' '\n'
fi
}
Output now:
view for arnold
Username
Password
User ID
Group ID
Directory
Shell
arnold
x
1003
1003
/home/arnold
/bin/bash
I also wish to change the output into table format as seen below. How do i do that? Thanks in advance!
view for arnold
Username arnold
Password x
User ID 1003
Group ID 1003
Directory /home/arnold
Shell /bin/bash