Operating System - Linux
1748201 Members
3734 Online
108759 Solutions
New Discussion юеВ

Re: how to get the Mac address....

 
SOLVED
Go to solution
Karthik_sg
Frequent Advisor

how to get the Mac address....

hi ppl,
I am using the following in the shell script
#!/bin/sh
MAC=`ifconfig | grep 'HWaddr '|cut -f 11 -d" "` ;
echo "$MAC";

But the output is 00:30:18:1D:4C:5A
And the desired output is 0030181D4C5A

Just tel me how to go about it.Thnks in advance


3 REPLIES 3
Denver Osborn
Honored Contributor
Solution

Re: how to get the Mac address....

MAC=`ifconfig | awk '/HWaddr/{print $NF}'|sed 's/://g'`
echo "$MAC"


-denver
skt_skt
Honored Contributor

Re: how to get the Mac address....

could you make your name a little smaller?
rick jones
Honored Contributor

Re: how to get the Mac address....

slight drift, but if the general way to express a MAC address is with the ':' in place, so if there is software out there which takes a MAC address and cannot handle the ':' it might be good to ask that it be fixed to do so.
there is no rest for the wicked yet the virtuous have no pillows