How to generate MD5 hashes with a Bash script
The following simple Bash script can be used to generate random MD5 hashes. To change the amount of hashes generated, you only need to change the value of the "limit" variable:
#!/bin/bash
counter=0
limit=10
while [ "$counter" -lt "$limit" ]
do
md5 -s "$counter $RANDOM `date`" | grep -o "[a-z0-9]\{32\}"
let "counter += 1"
done
echo
exit 0
To run this script from the command line (in my examples below the script is saved to "md5.sh"), you would use the command line to navigate to its directory and enter:
sh md5.sh
To run this script from the command line and save the output to a file, you would use the command line to navigate to its directory and enter:
sh md5.sh > output.txt
If you’re working on a Mac, you can run this script by double-clicking it in the Finder if you give the file a ".command" extension instead of ".sh", just remember to modify its permissions to executeable first.