Linux/motd
< Linux
__________________________________
< My hostname is SOMESYS >
< My IP Address is 10.0.0.1 >
----------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
/etc/profile.d/motd.sh
#!/bin/bash
_hostname=$(hostname)
#_ip_address=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')
_ip_address=$( ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/' )
len_hostname=${#_hostname}
len_ip_address=${#_ip_address}
pad=$(printf '%0.1s' " "{1..40})
padlength=35
printf "\n\n\n\n\n"
printf '%s\n' " __________________________________"
printf '%s %*.*s>\n' "< My hostname is ${_hostname}" 0 $((padlength - ${#_hostname} - 18 )) "$pad"
printf '%s %*.*s>\n' "< My IP Address is ${_ip_address}" 0 $((padlength - ${#_ip_address} - 20 )) "$pad"
printf '%s\n\n\n\n' " ----------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\\
||----w |
|| ||"