Guys I have a question I have a txt file full of names and I want to hash to md5sum for all the names in the txt at once with one by command Can you help with that and thanks in advance.

Thank you very much for your help, but there is a problem when I make the command line convert the texts to the normal md5 encoder, but I want it in md5sum format because when I encode this name, for example, Jeremy Bowers with this command line

echo "Jeremy Bowers" | $(command -v md5sum || command -v md5)

encodes the name like this


but with that command I used this

while read -r line; do printf %s "$line" | md5sum | cut -f1 -d' '; done < {filename} > {output filename}

it shows me all the names normal md5 encoding like this


It works for me but it shows me all the texts in the normal md5 encoding way and not md5sum so I want the same text command that does the same as the one I have this

echo "Jeremy Bowers" | $(command -v md5sum || command -v md5)

but I want it to encode all the names inside the text line by line and thank you in advance.

  • Do you want to produce a hash of the entire file, or hash each individual name seperatley?
    – nose_gnome
    Mar 23, 2022 at 16:34
  • If you think one of the answers is correct, please accept the answer by clicking on the gray check mark ✔️ and turn it green ✅.
    – user68186
    Mar 23, 2022 at 22:40
  • I haven't solved my problem yet and you can now read more about what I mean, and if it's difficult and you don't understand what I mean well, we can talk on Discord and show you what I mean Mar 24, 2022 at 9:36
  • See this question and answer to understand why you get a different result when you use echo "Jeremy Bowers" | mdsum versus while read -r line; do printf %s "$line" | md5sum | cut -f1 -d' '; done < {filename} > {output filename}. The difference is the newline char added at the end by echo.
    – user68186
    Mar 24, 2022 at 18:13
  • Thanks a lot for the clarification but I was wondering how I can do the command line, while read -r line; do printf %s "$line" | md5sum | cut -f1 -d' '; done < {filename} > {output filename} with that newline to get my same results and thanks in advance Mar 25, 2022 at 14:17

2 Answers 2


If you want to hash the entire file, you simply run

md5um {filename}

If the names are separated by new lines, you could hash each new line in the file using the following command

while read -r line; do printf %s "$line" | md5sum | cut -f1 -d' '; done < {filename}

This loops through each new line, printing to the terminal the hash of each line.

If you then want it to either write these hashes to a new file, or over-write the already existing file, you add > {filename}

Making this:

while read -r line; do printf %s "$line" | md5sum | cut -f1 -d' '; done < {filename} > {output filename}

In all of the above examples, you will need to replace {filename} with the path to the file you want to hash, and replace {output filenames} with the path to where you want the hashes to be outputed

  • 1
    YOOO bro I love youu bro thanks a looot Mar 23, 2022 at 21:23

With perl:

perl -MDigest::MD5=md5_hex -lne 'print md5_hex($_)' file.txt

You must log in to answer this question.

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