Created
April 9, 2018 18:42
-
-
Save skehlet/a4742cf78c434a5c26d84728c58e0d47 to your computer and use it in GitHub Desktop.
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
$ docker run --rm -it ubuntu bash | |
root@b327e1a0640b:/# function file_ends_with_newline() { | |
> [[ $(tail -c1 "$1" | wc -l) -gt 0 ]] | |
> } | |
root@b327e1a0640b:/# | |
root@b327e1a0640b:/# touch empty.txt | |
root@b327e1a0640b:/# | |
root@b327e1a0640b:/# | |
root@b327e1a0640b:/# file_ends_with_newline empty.txt && echo ends in newline || echo does NOT end in newline | |
does NOT end in newline | |
root@b327e1a0640b:/# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment