I'm currently writing a Bash script which hashes each line of a text file and outputs it into a new file with the format hash:orginalword
. The script I have at the moment to do this is:
cat $originalfile | while read -r line; do
hash="$(printf %s "$line" | $hashfunction | cut -f1 -d' ')"
echo "$hash:$line" >> $outputlocation
done
I originally got the code for this from a very similar question linked here. The script works exactly as advertised; however, the problem is that even for extremely small text files (<15KB) it takes a very long time to process.
I would really appreciate it if someone could suggest a script which achieves exactly the same outcome but does so far more efficiently.
Thank you in advance for any help,
Kind regards, John