I\'m trying to write a little script which will open a text file and give me an md5 hash for each line of text. For example I have a file with:
123
213
312
<
Almost there, try this:
while read -r line; do printf %s "$line" | md5sum | cut -f1 -d' '; done < 123.txt
Unless you also want to hash the newline character in every line you should use printf
or echo -n
instead of echo
option.
In a script:
#! /bin/bash
cat "$@" | while read -r line; do
printf %s "$line" | md5sum | cut -f1 -d' '
done
The script can be called with multiple files as parameters.