-1

how do I open a file of strings, hash the strings, and close it in bash? I am using MacOS X Yosemite.

1
  • 1
    What have you tried - and why in bash - a scripting language would be easier and what do you mean by hash
    – mmmmmm
    Sep 29, 2015 at 16:19

1 Answer 1

2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .