Check if a file ends with newline
Table of Contents
The following command will return 1 if the file ends with a newline, and 0 otherwise:
tail -c1 <file> | wc -l
Or as a function:
function file_ends_with_newline() {
[[ $(tail -c1 "$1" | wc -l) -gt 0]]
}