Last active
May 26, 2016 22:35
-
-
Save Lemmings19/afe7d9ac20483204cd14 to your computer and use it in GitHub Desktop.
Add newline to end of files without them.
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 | |
echo "Adding newlines to files that don't have them." | |
echo "Each dot represents a file that has had a line added." | |
# Loop through files in the given directory with the given extensions | |
for f in $(find /var/www/project-name/ -name "*.php" -or -name "*.phtml" -or -name "*.js"); do | |
# If the file doesn't end in a new line, add one. | |
if [ "$(tail -c1 "$f"; echo x)" != $'\nx' ]; then | |
echo "" >>"$f" | |
echo -n "." | |
fi | |
done | |
echo "All done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment