Overlord
Overlord

Reputation: 21

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!

Upvotes: 2

Views: 1292

Answers (1)

John1024
John1024

Reputation: 113814

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.

Upvotes: 3

Related Questions