Get MAC address without colons :'s - or - text from delimited items

I’m trying to retrieve the eth0 MAC address without the colons (:'s). I can delimit it well enough, but I need to reform the list of MAC address text items into a single text item. That is where I’m stuck. Here is what I have…

set longMAC to ""
set AppleScript's text item delimiters to {""}

set longMAC to do shell script "ifconfig en0 | grep ether"
set longMAC to characters ((length of longMAC) - 17) thru ((length of longMAC) - 1) of longMAC as text
set AppleScript's text item delimiters to {":"}
set newMAC to text items of longMAC

This gives me a result like this… {“00”, “11”, “aa”, “22”, “bb”, “33”}. In the end, I need something like this “0011aa22bb33”.

Thanks for any ideas.

Try this:

set longMAC to ""
set astid to AppleScript's text item delimiters
set longMAC to do shell script "ifconfig en0 | grep ether"
set longMAC to characters ((length of longMAC) - 17) thru ((length of longMAC) - 1) of longMAC as text
set AppleScript's text item delimiters to {":"}
set newMAC to text items of longMAC
set AppleScript's text item delimiters to astid
newMAC as text

By setting the delimiters to a variable, you can re-set them more accurately after you have finished. Then, simply set your list of text items to text.

Good luck,

Hi,

try this


set longMAC to do shell script "/sbin/ifconfig en0 | /usr/bin/awk '/ether / {print $2}' | /usr/bin/tr -d ':' "