Created
May 27, 2021 05:29
-
-
Save orvn/8b61850925388f0d21d1bcf13c254cd7 to your computer and use it in GitHub Desktop.
Sed append newline to all files that don't have one
This file contains hidden or 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
#### Find and append a newline to all files that do not already have one | |
## Regular operation for most *nix | |
find ~/my-path/ -type f -exec sed -i -e '$a\' {} \; | |
## MacOS compatible sed | |
find ~/my-path/ -type f -exec sed -i '' -e '$a\' {} \; | |
## (for find commands, consider controlling the nesting level with max-depth) | |
## Git compatible search (assumes current working directory is a repo) | |
git ls-files -z | xargs sed -i -e '$a\' | |
## Git compatible search and MacOS compatible sed | |
git ls-files -z | xargs sed -i '' -e '$a\' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment