Last active
February 22, 2023 08:02
-
-
Save WesselAtWork/4ab3612c68997623af9376b061a2330c to your computer and use it in GitHub Desktop.
Provides functions for the incremental building or streaming of tar archives
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/sh | |
| # | |
| # Provides commands for the incremental building or streaming of tar archives | |
| # NOTICE: Do not use compression flags on the input to tarfrg! | |
| # I am not checking you! | |
| # Use in the pipeline instead. e.g. `tarfrg ./tmp/* | tarfrgasm | gzip > archive.tar.gz` | |
| ####################################### | |
| # Creates tar file fragments | |
| # Arguments: | |
| # tar arguments | |
| # Forbiden Arguments: | |
| # tar compression arguments (like `-z`) | |
| ####################################### | |
| tarfrg() { | |
| #DO NOT USE COMPRESSION!!! | |
| tar c -O "$@" | head -c -1024 | |
| } | |
| ####################################### | |
| # Asembles tar file fragments form tarfrg | |
| # Input: | |
| # tarfrg output | |
| ####################################### | |
| tarfrgasm() { | |
| cat "$@" && head -c 1024 < /dev/zero | |
| } | |
| ####################################### | |
| ## Usage Examples: | |
| # tarfrg ./file.txt ./file2.txt | tarfrgasm > archive.tar | |
| # tarfrg ./* | tarfrgasm > archive.tar | |
| ## Incremental archive building | |
| # tarfrg ./file.txt > archive.tar.frg; | |
| # tarfrg ./file2.txt >> archive.tar.frg; | |
| # tarfrgasm archive.tar.frg > archive.tar; | |
| ## Working with applications that generate a stream of files | |
| ## filegeneratingapp outputs a stream of filenames to stdout as it writes files to the output-files directory | |
| # filegeneratingapp --output-files /workdone | xargs tarfrg | tarfrgasm | gzip > /writeonly/work.tar.gz | |
| ####################################### |
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/sh | |
| tar c -O "$@" | head -c -1024 |
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/sh | |
| cat "$@" && head -c 1024 < /dev/zero |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment