简体   繁体   中英

Creating a shell script to traverse a file system and hash every file

I need to create a shell script that will traverse my entire file system, hash each file, and write it into a text database.

I will be doing this on Ubuntu 12.04 and using md5sum and, if we are being honest here, I don't even know where to begin. Any and all help would be appreciated!

This may take some time to compute:

find / -type f -exec md5sum {} + >my_database.md5

How it works

  • find

    find is a utility that can traverse entire filesystems

  • /

    This tells find to start at the root of the filesystem.

  • -type f

    This tells find to find only regular files

  • -exec md5sum {} +

    This tells find to run md5sum on each of the files found.

  • >my_database.md5

    This tells the shell to redirect the output from the command to a file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM