LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Blogs > sag47
User Name
Password

Notices

Old

Using a script to get your IP address

Posted 01-07-2013 at 11:33 AM by sag47

A friend of mine was complaining today how their work place doesn't parse the IP address from ifconfig but asks for manual input from the user. This is the dumbest thing ever. In case you're ever encountered by this here's a horrible one liner to get the job done quick and dirty.

Also, you may need to replace eth2 with your correct interface (such as eth1).
Code:
ifconfig | sed -ne '/^eth2/,/^\s\+Interrupt/p' | awk '$0 ~ /inet addr/ { print $2 }' | cut -d: -f2
It...
Senior Member
Posted in Uncategorized
Views 3791 Comments 2 sag47 is offline

  



All times are GMT -5. The time now is 01:34 PM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration