Skip to content

Instantly share code, notes, and snippets.

@klopp
Created November 24, 2019 13:04
Show Gist options
  • Save klopp/98b442ff603da6e13e9f33c4df326200 to your computer and use it in GitHub Desktop.
Save klopp/98b442ff603da6e13e9f33c4df326200 to your computer and use it in GitHub Desktop.
Поиск и конвертирование файлов с виндовыми переводами строк
#!/bin/bash
SRC="."
for FILE in $(find "$SRC" -type f -regex ".*[.]\(p.\|[it]?html\|php\|cgi\|t\|js\|s?css\|feature\|sql\|yml\|json\|txt\)$")
do
R=$(grep $'\r' "$FILE")
if [ -n "$R" ]; then
echo "$FILE"
TEMPFILE=$(tempfile)
getfacl -p "$FILE" > "$TEMPFILE.acl"
cat "$FILE" | tr -d '\r' > "$TEMPFILE"
mv -f "$TEMPFILE" "$FILE"
setfacl --restore "$TEMPFILE.acl"
rm "$TEMPFILE.acl"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment