2

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!

Overlord
  • 21
  • 2
  • A basic shell script should work fine, you can redirect output into a text file. – James Wong Mar 17 '15 at 03:18
  • I would start by reading about shell scripting, specifically working with files, and the file system. You'll need to do a tree-traversal so that would be good to read about as well. – Mike Lyons Mar 17 '15 at 15:25

1 Answers1

3

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.

John1024
  • 109,961
  • 14
  • 137
  • 171