Skip to content

Instantly share code, notes, and snippets.

@szarnyasg
Last active April 21, 2020 22:46
Show Gist options
  • Save szarnyasg/c7779043169eb6c7f46df3405cd2c7b5 to your computer and use it in GitHub Desktop.
Save szarnyasg/c7779043169eb6c7f46df3405cd2c7b5 to your computer and use it in GitHub Desktop.
Save space for in-place sed with zstd
# compress $FILE with zstdmt
# remove $FILE
# print the header, decompress $FILE.zst afterwards and write them into $FILE
# delete $FILE.zst
FILE=myfile; zstdmt $FILE -f && rm $FILE && echo NEW_HEADER | cat - <(unzstd -c $FILE.zst | tail -n +2) > $FILE && rm $FILE.zst
# compress $FILE with zstdmt
# remove $FILE
# decompress $FILE.zst and perform the sed operation (substituting "FROM" to "TO")
# delete $FILE.zst
FILE=myfile; zstdmt $FILE -f && rm $FILE && unzstd -c $FILE.zst | sed 's/FROM/TO/' > $FILE && rm $FILE.zst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment