Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

How to get the IP address assigned to eth0 by a single command

Answer:

Only a single command is needed to return only the IP address assigned to eth0:

# echo $(ifconfig eth0 | awk -F: '/inet addr:/ {print $2}' | awk '{ print $1 }')
58.23.182.42

  1. How to send an email using a single command?
  2. Serve current directory using HTTP with a single command
  3. What is the difference between ip address 0.0.0.0 and 127.0.0.1?
  4. How to combine the output of multiple commands into a single file?
  5. Check for the number of connection from a particular IP address

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>