Skip to content

Instantly share code, notes, and snippets.

@hfs
Created March 21, 2014 10:51
Show Gist options
  • Save hfs/9683692 to your computer and use it in GitHub Desktop.
Save hfs/9683692 to your computer and use it in GitHub Desktop.
Replace \r\r\n with \r\n in text files. \r\r\n happens typically, when an inferior VCS messes up the line endings on Windows
#!/bin/sh
find . -type f | while read each; do
if xxd -p "$each" | tr -d '\n' | grep -q 0d0d0a; then
echo "$each"
sed -i.bak -e 's/\r//' "$each"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment