Skip to content

Instantly share code, notes, and snippets.

@krisk0
Created July 27, 2025 07:24
Show Gist options
  • Select an option

  • Save krisk0/1ece8062864145b074294977e98a18e0 to your computer and use it in GitHub Desktop.

Select an option

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)
#!/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