Skip to content

Instantly share code, notes, and snippets.

@lukrizal
Created March 11, 2015 00:43
Show Gist options
  • Save lukrizal/7a9decf109afa34d7f35 to your computer and use it in GitHub Desktop.
Save lukrizal/7a9decf109afa34d7f35 to your computer and use it in GitHub Desktop.
Useful Bash Scripts
#!/usr/bin/env bash
# Example
# $ . checking-user-if-exist.sh root
q=$(id -u $1)
re='^[0-9]+$'
if ! [[ $q =~ $re ]] ; then
echo "User $1 not found!" >&2;
fi
if [[ $q =~ $re ]] ; then
echo "User $1 found!" >&2;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment