Skip to content

Instantly share code, notes, and snippets.

@hexium310
Last active November 3, 2018 09:51
Show Gist options
  • Save hexium310/1e1b76a6e2f0d50a8e8d5dda8cbc7e51 to your computer and use it in GitHub Desktop.
Save hexium310/1e1b76a6e2f0d50a8e8d5dda8cbc7e51 to your computer and use it in GitHub Desktop.
Display the files (*.php or *.js) which end with the duplicate new lines under the current directory.
array=$(find . -type d \( -name 'node_modules' -o -name 'vendor' \) -prune -o -type f \( -name '*.js' -o -name '*.php' \) -print)
for a in $array; do
start=$(expr $(wc -c < $a) - 2)
[[ $start -lt 0 ]] && continue
new_line=$(hexdump -s $start $a | cut -c 9-13)
[[ $new_line = '0a 0a' ]] && echo "$a: $new_line"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment