If you care less about space efficiency and more about maintainability of the script, you can also encode the binary as base64 and put an
echo '...base64 data...' | base64 -d > somefile
in your script.Or add compression to reclaim at least some of the wasted space:
echo '...base64 gzipped data...' | base64 -d | gunzip > somefile
Also note that bash accepts line breaks in quoted strings and the base64 utility has an "ignore garbage" option that lets it skip over e.g. whitespace in its input. You can use those to break up the base64 over multiple lines: echo '
...base64 gzipped data...
...more data...
...even more data...
' | base64 -di | gunzip > somefile
Is there an encoding that is less wasteful that base64 but not vulnerable to text editor corruption issues? I think avoiding 0x0 to 0x20 should be enough to not get corrupted by text editors, though base64 avoids a lot more than that.
If you can count on every printable ascii character being not-mangled, you can use ascii85/base85/Z85 (5 "ascii characters" to 4 bytes) instead of base64.
There's probably a base(bigger number) with Unicode chars today
Base65536? https://github.com/qntm/base65536