Skip to content

Instantly share code, notes, and snippets.

@segyges
Last active March 3, 2024 01:30
Show Gist options
  • Select an option

  • Save segyges/5f13fc4af8d93ed4ccebbe4ccc36d536 to your computer and use it in GitHub Desktop.

Select an option

Save segyges/5f13fc4af8d93ed4ccebbe4ccc36d536 to your computer and use it in GitHub Desktop.
lfs_parity_checker.sh
#!/bin/bash
lfs_files_long=$(git lfs ls-files --long)
checked=0
bad=0
while IFS= read -r line; do
# Read each part of the line into separate variables
read -r hash separator filename <<< "$line"
# Echo each part with a different prefix
echo "Checking $filename with git lfs hash $hash"
# You can process each part further here if needed
computed_hash=$(sha256sum "$filename" | awk '{print $1}')
# Compare the computed hash with the provided hash
if [ "$computed_hash" = "$hash" ]; then
echo "File $filename: Hash matches"
else
echo "File $filename: Hash does not match, computed hash from file is $computed_hash"
((bad++))
fi
((checked++))
done <<< "$lfs_files_long"
if [ "$bad" -ne 0 ]; then
echo "$bad have bad checksums"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment