╲╲╲╱╱╲╲╱╲╲╲╱╲╲╲╲╲╲╱╲╱╲╱╱╲╱╱╱╲╱╱╱╲╲╲╲╱╲╱╱╱╱╲╱╲╲╱╱╲╲╲╱╱╲╱╲╲╱╲╱╱╲╱╲╱╲╲╲╱╲╲╱╲╲╱╱╱╲╱╲╲╲╱╲╲╲╲╲╲╱╱╲╱╱╱╲╲╱╲╲╱╲╱╱╱╱╲╱╱╱╱╲╲╲╱╲╲╱╲╱╱╲╱╲╱╲╱╲╲╲╲╲╱╲╱╲╲╲╲╲╲╲╱╲╲╱╲╲╱╱╱╲╱╱╲╱╲╱╱╱╲╲╲╲╲╲╱╱╲╱╱╲╲╱╲╲╲╲╱╱╱╱╲╲╱╱╱╲╱╱╱╱╲╲╲╲╲╲╲╲╱╲╱╱╲╱╲╲╱╱╱╲╲╲╱╲╲╱╱╲╲╲╱╲╲╱╱╱╱╱╲╱╱╲╱╲╱╱╱╱╱╲╲╲╲╱╱╱╲╱╲╲╱╱╲╱╲╲╲╲╲╲╱╱╱╲╲╲╱╲╲╲╱╲╲╱╱╱╲╱╱╲╱╱╱╲╱╲╲╱╱╲╱╲╲╲╲╱╲╲╱╲╱╱╲╱╲╱╲╲╲╲╱╲╱╲╲╲╱╱╱╲╲╲╲╱╲╱╲╲╱╲╲╲╲╱╲╲╲╱╲╱╲╱╱╲╲╱
Original author unknown (I believe off of a wifi hacking forum). Used in conjuction with ifconfig and cron.. can be handy (especially spoofing AP's) Show Sample Output
Use the following variation for FreeBSD:
openssl rand 6 | xxd -p | sed 's/\(..\)/\1:/g; s/:$//'
Generate a random MAC address with capital letters
Just increase the 1 at the end if you want to generate more than one. (Alternative to "| head -n N" you could use the -b flag of od: -b $[6*N] Show Sample Output
Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?
You must be signed in to comment.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
while :; do COMMAND; done
. Next, tidy the test condition and get rid of expr (an external command). Bash supports doing maths in $((...))if [ $(($RANDOM % 2)) -eq 0 ]; then ...
Personally, I'd change the "-eq 0" to "= 0" Yes, that's a string comparison, but it's nicer to read. . Next, replace the if statement with some boolean operators. '[' is a command in its own right: man test(1) If you've only got two one-command options, you can write:[ TEST-CONDITION ] && TRUE-COMMAND || FALSE-COMMAND
. Combine all the above and you get:while :; do [ $(($RANDOM % 2)) = 0 ] && echo -ne "\xE2\x95\xB1" || echo -ne "\xE2\x95\xB2"; done
. Because it only uses bash builtin commands it's much quicker, too.echo -ne "\xE2\x95\xB1"
echo -ne "\xE2\x95\xB2"
. So I need to substitute a 1 or a 2 into an echo. . Adding 1 to the previous random number:echo $((RANDOM%2+1))
. And substitute for the test condition:while :; do echo -ne "\xE2\x95\xB$((RANDOM%2+1))"; done
. Much nicer.