LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 04-27-2009, 07:37 AM   #1
sebelk
Member
 
Registered: Jan 2007
Posts: 66

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


Hi,

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, 08:02 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 110Reputation: 110
Code:
#!/bin/bash
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, 06:56 AM   #3
sebelk
Member
 
Registered: Jan 2007
Posts: 66

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Hko View Post
Code:
#!/bin/bash
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

Greets!
 
Old 04-28-2009, 07:07 AM   #4
pixellany
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:
 
  


Reply


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 08:14 AM
How to find an IP address from the MAC address of a remote machine ? jitz Linux - General 3 01-03-2006 07:55 AM
How to find IP address of a machine if I know their MAC Address dysenteryduke Linux - Networking 13 09-12-2005 10:21 AM
How to find MAC address of a specified IP address ? longtongfish Programming 1 07-12-2005 03:26 PM
how can i find mac address compzoo Linux - Networking 3 02-03-2005 02:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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