Skip to content

Conversation

@ruv
Copy link

@ruv ruv commented Sep 21, 2025

  • Remove spaces before line terminators.

    • Shell command: fd -t f | xargs grep -E -l '\s$' | xargs sed -i -E -e 's|\s+$||g'
  • Add a line terminator to the last line of the file if it is missing.

    • Shell command: fd -t f | xargs grep -Pz -l -v '\n$' | xargs sed -i -e '$s|$|\n|'

See-also: https://stackoverflow.com/questions/591923/make-git-automatically-remove-trailing-white-space-before-committing

- Remove spaces before line terminators.
  Shell command:
    fd -t f | xargs grep -E -l '\s$' | xargs sed -i -E -e 's|\s+$||g'

- Add a line terminator to the last line of the file if it is missing.
  Shell command:
    fd -t f | xargs grep -Pz -l -v '\n$' | xargs sed -i -e '$s|$|\n|'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant