LC_ALL=C printf "x:x:x:x:x:x\n" "'$"įirst line reads 6 characters from /dev/urandom then using the C character set print the 0-filled hex value of each character separated with a colon (the newline is optional but useful to print out the value). Just for fun, here is a pure bash version, tested against Bash 4.4.12(1)-release: read -N6 b OS X's od ( /usr/bin/od below) uses a different output format than GNU od: $ /usr/bin/od -N6 -tx1 -An /dev/random|tr ' ' : ![]() In jot -w changes the format, -s changes the separator, and -r generates random numbers. Jot comes with OS X and BSDs but not with most Linux distributions. God -N6 -tx1 -An /dev/random|cut -c2-|tr \ : Openssl rand -hex 6|fold -w2|paste -sd:. ![]() Here are five other options, all of which use random bits for the least significant bit of the most significant byte that indicates if the address is unicast or multicast and for the second-least significant bit of the most significant byte that indicates if the address is universally or locally administered.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |