whiteletters in blankpapers whiteletters in blankpapers - 1 year ago 102
Linux Question

Command for printing IP address in Ubuntu not understood

It is the first time I use a Linux distribution and I find --help very difficult to use in order to unserstand the following command:

ifconfig eth0 | grep inet | awk '{ print $2 }'

Someone to explain to me please what the words of this command do? what is the name of
in english?

Answer Source

The | sign called pipeline and it is an operator that sends the output of the command in it left side as the input of the command in it right side.

So basicly, you have 3 commands:

ifconfig eth0

which outputs many details on your network, then you send that output to:

grep inet

which takes only the lines that contain the word inet and send that to:

awk '{ print $2 }'

which print the just seconed word.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download