Created
June 28, 2016 19:08
-
-
Save ImIOImI/69396399f5c401e68463d363990a2023 to your computer and use it in GitHub Desktop.
This is a bash script I ran on cygwin that finds all the php files in a directory tree and converts them from lf to crlf
This file contains 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 | |
FOLDER=$(pwd) | |
arrayname=( $(find $FOLDER -name '*.php') ) | |
fixarray=() | |
for element in $(seq 0 $((${#arrayname[@]} - 1))) | |
do | |
filename=${arrayname[$element]}; | |
fileOut="$(file $filename)"; | |
if [[ $fileOut != *"CRLF"* ]]; | |
then | |
fixarray+=( "${arrayname[$element]}" ) | |
fi | |
done | |
for element in $(seq 0 $((${#fixarray[@]} - 1))) | |
do | |
echo "${fixarray[$element]}" | |
done | |
echo 'Convert the files above to CRLF? (y/n)' | |
read SELECTION | |
if [ ${SELECTION} == "y" ]; | |
then | |
for element in $(seq 0 $((${#fixarray[@]} - 1))) | |
do | |
echo "${fixarray[$element]}" | |
perl -pi -e 's/\n/\r\n/' "${fixarray[$element]}" | |
rm "${fixarray[$element]}.bak" | |
done | |
else | |
echo "Not doing anything!" | |
exit | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment