What's up guys got a quick question,
I'm studying for the linux+ exam and I've come across this command which has me kind of baffled. The command itself is very simple however using it to cut out a section and echo it into the terminal has be kind of confused. Let me explain.
the example has the output of ifconfig which looks like this. I'm trying to extract the hardware address and just have it echo in terminal
$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:76:96:A3:73
inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:76ff:fe96:a373/64 Scope:Link
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7127424 errors:0 dropped:0 overruns:0 frame:0
TX packets:5273519 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6272843708 (5982.2 Mb) TX bytes:1082453585 (1032.3 Mb)
Interrupt:10 Base address:0xde00
The cut command in which I would like to use goes something like this:
$ ifconfig eth0 | grep HWaddr | cut -d “ “ -f 11
00:0C:76:96:A3:73
Now what I'm confused about is why when we set the field switch to 11 (-f 11) does it give us the hardware address we want?? the -d makes a space character the delimiting field but I'm not counting 11 space characters before the hardware address? My intuition would lead me to pass the command
$ ifconfig eth0 | grep HWaddr | cut -d “ “ -f 9 (since I count nine space characters from the begging of hte output to the begging of the hardware address)
00:0C:76:96:A3:73
if anyone can clear this up for me I'd greatly appreciate it.