Skip to content

Instantly share code, notes, and snippets.

@ipan
Last active January 16, 2018 06:34
Show Gist options
  • Save ipan/599084e90f8a87da03746c28bba0b143 to your computer and use it in GitHub Desktop.
Save ipan/599084e90f8a87da03746c28bba0b143 to your computer and use it in GitHub Desktop.
add new lines to json files when there is no newline char #git #ls-files #read
# only add when the json file does not have new line
git ls-files | grep json | while read f; do tail -n1 $f | read -r _ || echo >> $f; done
# https://unix.stackexchange.com/questions/31947/how-to-add-a-newline-to-the-end-of-a-file
# https://unix.stackexchange.com/questions/192786/what-is-the-meaning-of-read-r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment