Skip to content

Instantly share code, notes, and snippets.

@chrisberkhout
Created October 9, 2014 09:20
Show Gist options
  • Save chrisberkhout/124e99eea6e0b4f0be92 to your computer and use it in GitHub Desktop.
Save chrisberkhout/124e99eea6e0b4f0be92 to your computer and use it in GitHub Desktop.
extralf: Extra Line Feed - select files with EOL-EOL-EOF
#!/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