Generate unique mac address | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Generate unique mac address

Shell Programming and Scripting


Tags
mac addres

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-08-2013
kriti kriti is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 22 February 2013, 12:29 AM EST
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
Computer Generate unique mac address

Hi,

I want to generate 2000 mac address. Please let me know how to do so.
Perl script or there is some tool availlable wherein i can give the count and it will generate that many mac-address

Thanks,
Kriti
Sponsored Links
    #2  
Old 02-08-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 1 August 2014, 2:47 PM EDT
Location: Aachen, Germany
Posts: 3,950
Thanks: 63
Thanked 939 Times in 891 Posts
You know that there's more to MAC addresses than just a sequence of 6 HEX numbers separated by : . But, as vague as you are in your request, this will do:
Code:
$ awk 'BEGIN {while (i < 2000) {a=sprintf ("%.12X", i++); gsub(/../,"&:",a); sub(":$","",a); print a}}'
00:00:00:00:00:00
00:00:00:00:00:01
.
.
.

The Following User Says Thank You to RudiC For This Useful Post:
kriti (02-08-2013)
Sponsored Links
    #3  
Old 02-08-2013
kriti kriti is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 22 February 2013, 12:29 AM EST
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
Thanks for your help. I am not into scripting. Just started with it. Can you tell me how to save the following code and run it into linux.
    #4  
Old 02-08-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 1 August 2014, 2:47 PM EDT
Location: Aachen, Germany
Posts: 3,950
Thanks: 63
Thanked 939 Times in 891 Posts
Copy / paste into terminal?
The Following User Says Thank You to RudiC For This Useful Post:
kriti (02-08-2013)
Sponsored Links
    #5  
Old 02-08-2013
kriti kriti is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 22 February 2013, 12:29 AM EST
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
Hey i got how to run it..


Code:
#!/usr/bin/awk -f
BEGIN {while (i < 2000) {
a=sprintf ("%.12X", i++);
gsub(/../,"&:",a);
sub(":$","",a);
print a
}
}

~

Save it in a file and run using below cli

Code:
echo | awk -f <file_name>


Last edited by Franklin52; 02-08-2013 at 08:11 AM.. Reason: Please use code tags for data and code samples
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Generate unique user id with each addition of data yonkers062986 Shell Programming and Scripting 4 11-29-2011 07:38 AM
How to generate 10.000 unique numbers? xrays Shell Programming and Scripting 7 10-01-2010 11:14 AM
Tracing a MAC address to IP address: Solaris DNT IP Networking 9 08-17-2010 08:10 AM
need to generate unique id from constant sid umen Shell Programming and Scripting 0 04-10-2006 05:08 AM
How to Achive IP address through MAC(Ethernet) address krishnacins IP Networking 3 08-29-2005 08:45 PM



All times are GMT -4. The time now is 12:28 AM.