Skip to content

Instantly share code, notes, and snippets.

@matthewpoer
Created January 4, 2020 22:48
Show Gist options
  • Save matthewpoer/ce32a109191c71a67305bb1e405a42b7 to your computer and use it in GitHub Desktop.
Save matthewpoer/ce32a109191c71a67305bb1e405a42b7 to your computer and use it in GitHub Desktop.
Get information about the files within a directory, including list of files, their sizes and md5 hashes.
#/usr/bin/env bash
# for a given directory myDirectory, create a list of all files within that directory
# note that file names are not enclosed in quotes here
find myDirectory -type f -exec echo {} \; > myDirectory.files.text
# if you want them in quotes,
# find myDirectory -type f -exec echo \"{}\" \; > myDirectory.files.text
# and a list of the sizes of each of these files
find myDirectory -type f -exec echo \"{}\" \; | xargs -n1 du -sh > myDirectory.files.sizes.text
# and a list of the sizes of each of these files
find myDirectory -type f -exec echo \"{}\" \; | xargs md5 > myDirectory.files.md5.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment