tag:blogger.com,1999:blog-27773648.post245351433136858358..comments2024-03-28T12:40:55.906+01:00Comments on m8t's blog: Random MAC addressMike Massonnethttp://www.blogger.com/profile/00582966565407297350noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-27773648.post-21105991641747965982010-06-01T10:32:33.523+02:002010-06-01T10:32:33.523+02:00" /\(..\)/\1 "
/ starts the expression
\..." /\(..\)/\1 "<br />/ starts the expression<br />\ escapes the (<br />( begins a sort of "clipboard"<br />. finds any character<br />. finds any character<br />\ escapes the )<br />) closes the clipboard<br />/ ends the search, begins the replacement<br />\ espaces the 1<br />1 pastes the clipboardFelipehttps://www.blogger.com/profile/14787358518273936179noreply@blogger.comtag:blogger.com,1999:blog-27773648.post-84814857807456138022010-05-16T12:20:41.614+02:002010-05-16T12:20:41.614+02:00"cho $RANDOM | openssl md5 | sed 's/\(..\..."cho $RANDOM | openssl md5 | sed 's/\(..\)/\1:/g' | cut -b0-17"<br /><br />Hey so I am starting to learn how to script and I was looking into mac generators.. <br /><br />I find this crazy line of code that looks like a little dude with his arms in the air<br /> " /\(..\)/\ "<br />And thru some witch craft this little dude spits out a mac address......<br /> I have no idea how it works but it does..<br /> This is an awesome piece of art Mike, nice job.Chrisnoreply@blogger.comtag:blogger.com,1999:blog-27773648.post-59696867947840523002009-09-17T18:10:02.547+02:002009-09-17T18:10:02.547+02:00the '-r' flag for sed cannot be used on Ma...the '-r' flag for sed cannot be used on MacOSX (10.6), use '-E' insteadJulian Kesselhttp://juliankessel.denoreply@blogger.comtag:blogger.com,1999:blog-27773648.post-90596805265859197642009-07-18T08:57:29.495+02:002009-07-18T08:57:29.495+02:00Very nice use of hexdump, however to be sure to al...Very nice use of hexdump, however to be sure to always have two hexa values %02x must be used for the format.Mike Massonnethttps://www.blogger.com/profile/00582966565407297350noreply@blogger.comtag:blogger.com,1999:blog-27773648.post-74374724723745452502009-07-18T05:58:48.856+02:002009-07-18T05:58:48.856+02:00No need for cut anyway...
sed -r 's/(..)/\1:/...No need for cut anyway...<br /><br />sed -r 's/(..)/\1:/g; s/^(.{14}).*$/\1/;'<br /><br />Also, I found /dev/random or /dev/urandom to be a more appropriate/useful source of random hex:<br /><br />MAC=00:`head -c5 /dev/urandom|hexdump -e '"%x"'| sed -r 's/(..)/\1:/g; s/:$//;'`Clayton Shepardhttps://www.blogger.com/profile/11139128931368750934noreply@blogger.comtag:blogger.com,1999:blog-27773648.post-48053409773218105002009-03-26T14:31:00.000+01:002009-03-26T14:31:00.000+01:00As on my router ther is no md5 command, I did:RAND...As on my router ther is no md5 command, <BR/>I did:<BR/><BR/>RANDOM=$(md5sum /proc/uptime | sed 's/\(..\)/\1:/g' | cut -c1-17)<BR/><BR/>regards, wwwolfAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-27773648.post-60308884281335552272008-11-13T18:29:00.000+01:002008-11-13T18:29:00.000+01:00Reading the comments... and reading the blog entry...Reading the comments... and reading the blog entry, I was also wondering for the cut command. This has changed since some time in the GNU coreutils, 0 prints an error now.Mike Massonnethttps://www.blogger.com/profile/00582966565407297350noreply@blogger.comtag:blogger.com,1999:blog-27773648.post-90461874090396812642008-08-27T00:26:00.000+02:002008-08-27T00:26:00.000+02:00# echo $RANDOM | openssl md5 | sed 's/\(..\)/\1:/g...# echo $RANDOM | openssl md5 | sed 's/\(..\)/\1:/g' | cut -b0-17<BR/>cut: [-cf] list: values may not include zero<BR/><BR/># echo $RANDOM | openssl md5 <BR/>(stdin)= 4b4f98e306dd3797ca1a05c8349b8005<BR/><BR/>Gives (stdin) at the begining...but:<BR/><BR/># echo $RANDOM | md5 | sed 's/\(..\)/\1:/g' | cut -c1-17<BR/>c6:af:4a:15:08:4b<BR/><BR/>...gives the result. This is on NetBSD though. Thnx for the tip, nice oneliner. :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-27773648.post-38910939326625783342007-11-15T05:18:00.000+01:002007-11-15T05:18:00.000+01:00very nice 1 linerMaster Foo would be pleasedvery nice 1 liner<BR/>Master Foo would be pleased0xC0FFEEhttps://www.blogger.com/profile/16933607670755283152noreply@blogger.com