Skip to content

Instantly share code, notes, and snippets.

@bittner
Created November 5, 2017 11:52
Show Gist options
  • Save bittner/75e38c41e6b9c9ff9814daefe311ae58 to your computer and use it in GitHub Desktop.
Save bittner/75e38c41e6b9c9ff9814daefe311ae58 to your computer and use it in GitHub Desktop.
Check files for DOS/Windows line endings.
#!/usr/bin/env bash
# -----------
# Check files for DOS/Windows line endings.
# -----------
[ -a "$1" ] || {
echo 'Check files for DOS/Windows line endings.'
echo "Usage: ${0##*/} {filename}"
exit 0
}
which dos2unix > /dev/null || {
echo 'This script requires dos2unix. Please run: sudo apt install dos2unix'
exit 2
}
dos2unix < $1 | cmp -s - $1;
[ $? -ne 0 ] && {
echo "- $1 has DOS/Windows line endings"
exit 1
}
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment