Skip to content

Instantly share code, notes, and snippets.

@fardjad
Created February 8, 2019 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fardjad/d4499ea3bbdc26b094b4cac175b7a110 to your computer and use it in GitHub Desktop.
Save fardjad/d4499ea3bbdc26b094b4cac175b7a110 to your computer and use it in GitHub Desktop.
[find-binary-files-in-git-repo.sh] Find binary files in a git repo #git #bash
#!/bin/bash
git_files=$(git ls-files)
for git_file in $git_files; do
encoding=$(file --mime-encoding "$git_file")
type=$(echo "$encoding" | awk -F ': ' '{ print $2 }')
if [ "$type" == "binary" ]; then
echo $git_file
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment