0
ifconfig | grep ether | cut -d " " -f 10

This is how I am trying to get the ether but I am on this for about 2 hours trying to understand why I am selecting 10th column to cut out when ether is on 2nd column.

I'm just trying to understand

enter image description here

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

1

Try

ifconfig | grep ether | sed 's/^[[:space:]]*//g' | cut -d " " -f 2

This will remove leading whitespace as per this SO-link and then you can use a single space as delimiter.

kometen
  • 6,536
  • 6
  • 41
  • 51
  • Oh that's very cool, What I understood is that when I'm trying to get mac address from my code above, -f 10 is after 10 " "(blankspace) comes actual mac and this is its colomn. – Nodirbek Anorboyev Sep 18 '22 at 20:56
  • 1
    You can take the blanc space and copy it into echo and pipe it to wc (word-count) `echo " " | wc`. This will show you how many characters the space is. But it is more reliable to delete any whitespace in front so you know first letter is a non-whitespace. – kometen Sep 18 '22 at 21:25