Skip to content

Instantly share code, notes, and snippets.

@jackprice
Created February 10, 2015 19:28
Show Gist options
  • Save jackprice/57c2595d638271b496de to your computer and use it in GitHub Desktop.
Save jackprice/57c2595d638271b496de to your computer and use it in GitHub Desktop.
Bash motd
#
# Shell script to print a motd with various bits of information about the system
# Included from .bashrc
#
# Get hostname
HOSTNAME=$(hostname)
# Get kernel version
KERNEL="$(uname -r) ($(uname -s))"
# Get uptime
UPTIME=$(uptime | sed 's/.*up \([^,]*\),.*/\1/')
# Get users
USERS=$(w | head -1 | sed 's/^.*\([0-9][0-9]*\) users.*$/\1/')
# Get storage
STORAGE=$(df / | grep / | awk '{print $8}')
# Get PHP version
PHP=$(php -v | egrep -o 'PHP [0-9]+\.[0-9]+\.[0-9]+' | awk '{print $2}')
# Echo
echo -e "
Hostname:\033[2m $HOSTNAME \033[0m
Kernel:\033[2m $KERNEL \033[0m
Uptime:\033[2m $UPTIME \033[0m
Users:\033[2m $USERS \033[0m
Storage:\033[2m $STORAGE used \033[0m
PHP:\033[2m $PHP \033[0m
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment