2021年3月4日星期四

How to use MD5 dictionary in bash?

I have an assignment due tomorrow morning that I've been trying to figure out for hours. I have to create an MD5 dictionary, read things into variables, and use conditionals to check for files. Below is the assignment for my class. I've been using the terminal on Mac since my prof said it would be fine, but if it's easier using Ubuntu, then I have a PC too. I hope I described the general idea well enough but I'm not really sure what I'm doing:

In your shell script (or in a new shell script), before you create the MD5 dictionary file from Part 1, check if the md5dict.txt file already exists. If it does, read each entry in the file and the MD5 hash into two bash variables. Use the file path variable, and if the file exists, compute md5sum on the file, storing the current MD5 hash into another variable. If the MD5 does not match the one you read in your original dictionary, print out that the file has changed to the screen. If the file no longer exists, print out a message indicating that as well. If the file exists and the MD5 hashes match, print nothing (this way, you have a concise log of all the files that have changed in your directory!).

Finally, we need to see if any new files were created. Use a find command to find all files in your current working directory. For each one, grep for it in your md5dict.txt file. If no match is found, print out hat you have identified a new file in your working directory.

https://stackoverflow.com/questions/66485746/how-to-use-md5-dictionary-in-bash March 05, 2021 at 10:07AM

没有评论:

发表评论