Tip #554 Get your machines IP adress
You sometimes need your machines IP adress without relying on external sources; so here is the command to return your IP adress in one neat line.ifconfig eth0 | grep -o "addr:[0-9.]*" | grep -o "[0-9.]*"
You off course need the necessary rights to us this. If you lack the rights, you might want to prepend it with "sudo" and add the ifconfig to the allowed paswordless commands for the user that needs this..
Ifconfig retrieves the adress; the first grep weeds out the external adress out of the data & the last grep filters out the IP adress.
- TAGS:
- grep
alias aptitude at awk bash bc cal cat cd colrm comm cp csh curl cut date dd df dialog diff dirname dpkg du fc find fuser grep gs gzip history iconv kill ksh last less ln ls lsof lynx m4 md5sum mkdir mkfifo mkisofs mv mysql nc netstat openssl OSX perl ping popd ps pushd python read redirection rm scp screen sed sort ssh stat sudo svn tail tar tee test top tr uniq vim wc wget xargs