Kavin Palaniswamy
Kavin Palaniswamy

Reputation: 181

Read file names from a list file one by one and create a md5 checksum list file in unix

I have a list file with file names listed:

List1.txt
File1
File2
File3
File4

I want to loop through the the file names in list 1 and generate another md5 checksum list file for each file present in the list 1.

Expected Output:

md5_list.txt
File1 MD5Value
File2 MD5Value
File3 MD5Value
File4 MD5Value

This is what i have come up with :

cat list1.txt | find -type f ! -name "list1.txt" -exec md5sum {} + | sort -k 2 > md5_list.txt

Would like to know if this is the right way ? If yes, is there a more efficient way of getting this done?

Thanks

Upvotes: 1

Views: 750

Answers (1)

Kavin Palaniswamy
Kavin Palaniswamy

Reputation: 181

The solution given by David C. Rankin in a comment worked for me:

sort < List1.txt | xargs md5sum > md5_list.txt

Upvotes: 1

Related Questions