3

Suppose I have multiple files in my folder:

HuZhou_1_d1_Clean_Data_unaligned.fq.2.gz 
HuZhou_1_d1_Clean_Data_unaligned.fq.1.gz 
HuZhou_1_d1_Clean_Data_unaligned.fq.3.gz 
HuZhou_1_d1_Clean_Data_unaligned.fq.4.gz

I want to generate hashes for each of these files. How may I write this script? I know I can generate hashes one by one with the code:

md5 /Users/zhangzhongheng/Downloads/HuZhou_1_d1_Clean_Data_unaligned.fq.4.gz 
MD5 (/Users/zhangzhongheng/Downloads/HuZhou_1_d1_Clean_Data_unaligned.fq.4.gz) = a0a05a8c499fdd84980c5989f30a2d7c 
1
  • If you show your script or what basics you have, we can also help with oaths. This is trivial from the interactive shell, but you may have requirements we can’t guess without seeing how much of a script you can assemble today.
    – bmike
    Nov 30 '21 at 12:15
9

Command line shells can perform wildcard expansion or file globbing to solve this easily.

In your case:

md5 HuZhou_1_d1_Clean_Data_unaligned.fq.*.gz

The shell handles passing all file names and md5 calculates the sum for each of those files matching the pattern in the current directory.

You must log in to answer this question.

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