Skip to content

Instantly share code, notes, and snippets.

@pyratebeard
Created April 25, 2017 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pyratebeard/ff19cefbe502ceaf61c97dc27c786aeb to your computer and use it in GitHub Desktop.
Save pyratebeard/ff19cefbe502ceaf61c97dc27c786aeb to your computer and use it in GitHub Desktop.
Search /etc/passwd for usernames
#!/bin/bash -
for user in $* ; do
user_search=$(grep -c $user /etc/passwd)
case $user_search in
0) printf "User '$user' does not exist\n" ;;
1) printf "User '$user' does exist\n" ;;
*) printf "Something went wrong\n" ;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment