Created
November 24, 2019 13:04
-
-
Save klopp/98b442ff603da6e13e9f33c4df326200 to your computer and use it in GitHub Desktop.
Поиск и конвертирование файлов с виндовыми переводами строк
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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