how do I open a file of strings, hash the strings, and close it in bash? I am using MacOS X Yosemite.
1 Answer
Your question is a bit short on details, but assuming that you have a file FILE.txt
where all the strings which need to be hashed are on separate lines, you could run something like
: > FILE.hash
while read line; do
md5 -rs "$line" >> FILE.hash
done < FILE.txt
This results in a text file FILE.hash
containing lines like
5eb63bbbe01eeed093cb22bb8f5acdc3 "hello world"
If you prefer to have the hashes without the text they represent, use
md5 -qs "$line" >> FILE.hash
instead.