Skip to content

Instantly share code, notes, and snippets.

@marcosrjjunior
Created January 10, 2023 03:46
Show Gist options
  • Save marcosrjjunior/990e376edba8e616f35be98ad648b52b to your computer and use it in GitHub Desktop.
Save marcosrjjunior/990e376edba8e616f35be98ad648b52b to your computer and use it in GitHub Desktop.
Listing and hashing files from directory sha256

List files from dir

find src/*

Excluding directories

find src/* -not -path "src/dir-name-to-exclude/*"

Filtering file extensions (.ts, .tsx)

find src/* -type f \( -iname \*.ts -o -iname \*.tsx \)

Sorting list

find src/* | sort

Hashing to sha256 and returning only the hash

find src/* | sort | xargs tail -n +1 | sha256sum | cut -d" " -f1)

Full command

find src/* -not -path "src/dir-name-to-exclude/*" -type f \( -iname \*.ts -o -iname \*.tsx \) | sort | xargs tail -n +1 | sha256sum | cut -d" " -f1)

This should return the hashed value. f21312762404d3bfc011cb22d2daf204640b3315f3d64656a3af3757083889

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment