Hamid's blog

Linux Hints: 1. Save md5sum of all files in all dirs/subdirs to a file

May 02, 2020

1. Save md5sum of all files in all dirs/subdirs to a file

shell command:

find /home/user -type f -exec md5sum {} \; >> /tmp/md5sum.txt

description:

  • /home/user

    • desired path to search for files. Change it to your desired path
  • -type f

    • only find files, not directories
  • -exec md5sum {} \;

    • executes md5sum command for each found file, represented by {} sign here.
    • has few parts:

      • -exec COMMAND_HERE \; execute the given command on a found file.
      • md5sum {} execute md5sum command on input passed by find command using {} symbol
  • >> /tmp/md5sum.txt

    • >> append output to file
    • /tmp/md5sum.txt is path of file

After executing this shell command, /tmp/md5sum.txt file will contain md5sum and file name of each file in given path, for this example /home/user.