Created
July 27, 2025 07:24
-
-
Save krisk0/1ece8062864145b074294977e98a18e0 to your computer and use it in GitHub Desktop.
Prepare CK3 mod (insert UTF-8 BOM, remove 0xD, end-of-line spaces)
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
| #!/bin/bash | |
| kill_0D() { | |
| perl -pi -e s/\\x0d//g $1 | |
| } | |
| BOM_INSERT() { | |
| sed -i '1s/^\(\xef\xbb\xbf\)\?/\xef\xbb\xbf/' $1 | |
| } | |
| do_with_file() { | |
| BOM_INSERT $f | |
| kill_0D $f | |
| } | |
| kill_trailing_space() { | |
| grep -q '[[:blank:]]$' $1 && sed -i 's/[[:blank:]]*$//' $1 | |
| } | |
| for f in `find -type f \( -name \*.txt -o -name \*.yml \)`; do | |
| do_with_file $f | |
| kill_trailing_space $f | |
| done | |
| for f in `find -type f -name \*.mod`; do | |
| kill_0D $f | |
| kill_trailing_space $f | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment