Created
October 9, 2014 09:20
-
-
Save chrisberkhout/124e99eea6e0b4f0be92 to your computer and use it in GitHub Desktop.
extralf: Extra Line Feed - select files with EOL-EOL-EOF
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 | |
if [ -z "$1" ] || [ "$1" = "--help" ]; then | |
echo "extralf: Extra Line Feed - select files with EOL-EOL-EOF" | |
echo "Usage: extralf FILE [FILE] [FILE]..." | |
echo "Example: find . -name '*.rb' | xargs extralf" | |
else | |
for file in "$@" | |
do | |
if [ -s "$file" ]; then | |
last_line=`tail -n1 $file` | |
if [ -z "$last_line" ]; then | |
echo $file | |
fi | |
elif [ -f "$file" ]; then | |
echo "empty file: $file" 1>&2 | |
else | |
echo "not a file: $file" 1>&2 | |
fi | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment