Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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