Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-27-2009, 08:37 AM   #1
Registered: Jan 2007
Posts: 66

Rep: Reputation: 15
Find possible combinations for a mac address


I need to find a mac address of a wireless route. I know its first four group but I want to know the last 2: nn:nn:nn:nn:xx:xx.

How can I do a bash or perl (or whatever) script that generate all possible combinations for xx:xx

Thanks in advance!
Old 04-27-2009, 09:02 AM   #2
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 110Reputation: 110
for((i=0;i<256;++i));do for((j=0;j<256;++j));do printf '%02X:%02X\n' $i $j;done;done
Old 04-28-2009, 07:56 AM   #3
Registered: Jan 2007
Posts: 66

Original Poster
Rep: Reputation: 15
Originally Posted by Hko View Post
for((i=0;i<256;++i));do for((j=0;j<256;++j));do printf '%02X:%02X\n' $i $j;done;done
Thanks Hko!

It was really useful although I don't know exactly what does "%02X" mean

Old 04-28-2009, 08:07 AM   #4
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
man printf

I think it sends you to the definition for the C version of printf---where you will find the definition of the formatting strings.

In this case:
'%02X:%02X\n' means
"print the following two arguments as 2-digit hex, separated by a ":", and followed by a newline:


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
find out MAC and IP address Micik Linux - Newbie 10 09-04-2006 09:14 AM
How to find an IP address from the MAC address of a remote machine ? jitz Linux - General 3 01-03-2006 08:55 AM
How to find IP address of a machine if I know their MAC Address dysenteryduke Linux - Networking 13 09-12-2005 11:21 AM
How to find MAC address of a specified IP address ? longtongfish Programming 1 07-12-2005 04:26 PM
how can i find mac address compzoo Linux - Networking 3 02-03-2005 03:02 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:23 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration