Skip to content

Instantly share code, notes, and snippets.

@shov
Last active May 18, 2017 09:28
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 shov/e7169839935b6a15682b25cae761a1f2 to your computer and use it in GitHub Desktop.
Save shov/e7169839935b6a15682b25cae761a1f2 to your computer and use it in GitHub Desktop.
Remove \r in all .sh in the current directory used tr
#!/bin/bash
function movement() {
local bname=$(basename "$1")
local fbname=${bname%.*}
mv "$1" "${fbname}"
}
find . -name '*.sh' -exec sh -c 'tr -d "\r" < "$0" > "$0.tmp"' '{}' \;
find . -name "*.sh.tmp" | while read file; do movement "$file"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment