[SOLVED] I am trying to get ether mac address it is in the second column

Issue

This Content is from Stack Overflow. Question asked by Nodirbek Anorboyev

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 field(coloumn) to cut out when ether is on 2nd coloumn
I’m just trying to understandenter image description here



Solution

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.


This Question was asked in StackOverflow by Nodirbek Anorboyev and Answered by kometen It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?