My first use of awk command


Hi,

today I has to detect the machines IP. So I thought to make use of “awk” for it and got build this command

ifconfig eth0 | awk ‘/inet addr:/ {print $2}’ | cut -d\: -f2

first get the ifconfig output to awk, find “inet addr:” in it (for ip version 6 use “inet6 addr” ) than cut it in piece and pick the second one

as simple as that