sort -R randomize the list. head -n1 takes the first.
Random text of length "$1" without the useless cat command.
ZSH ships a couple random number generators via the $RANDOM environment variable and rand48() via zsh/mathfunc, but neither are cryptographically secure. This code produces a 32-bit random number suitable for cryptography. It's only dependency is /dev/urandom and it does not rely on any shell commands or 3rd party utilities. It assumes ZSH was compiled with 64-bit integer support. Show Sample Output
This is just for fun. Show Sample Output
Makes use of $RANDOM environment variable.
Splitting on tags in awk is a handy way to parse html.
Ever need to get some text that is a specific number of characters long? Use this function to easily generate it! Doesn't look pretty, but sure does work for testing purposes! Show Sample Output
Using urandom to get random data, deleting non-letters with tr and print the first $1 bytes.
Here's my version. It's a bit lengthy but I prefer it since it's all Bash.
Use less random number resources and less commands
This one is for OS X users: sort -R and shuf aren't available in Lion (10.7.5)
This provides better, but not perfect, distribution, and it works for 2^32 ≤ X ≤ 2^64. (A robust distribution requires iteration/recursion and an indeterminate amount of randomness.)
Great for backup / restore scripts. May want to remove the %M/%S to group backups by hour. If using a script, set a variable earlier with the date command, then reference that variable. Otherwise, time will keep on rolling ;-) declare -rx script_start_time="$(date '+./%Y/%m/%d/%H/%M/%S')" mkdir -p "$script_start_time" Show Sample Output
Create a file with random binary content. Required pv, units packages. It use openssl to encrypt zeros using aes-256 and time stamp as password to generate a pseudo-random file. Show Sample Output
seed the random number generator, find all matches in a file put all matches from the capture group into an array return a random element from the array Show Sample Output
This server can be access by a browser or other remote terminal with ncat. I have to use de test && break to allow ctrl-c to close. Show Sample Output
This might one day deliver the melody to the next super hit on the radio if played long enough
Piping dd through pv allows to control the size ot the output file and allows for feedback on speed and progress. Sample output is 128 bytes as seen with xxd. See also: http://www.red-bean.com/onetime/#pad-generation Show Sample Output
You can put this at .bashrc or .profile and get a random tip every time you open a terminal Show Sample Output
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: