This is an answer - and may do what you want:
tar xf tarball-test.tar.gz --to-stdout | fold -w 80 -s > output.txt
alternative:
tar zxOf tarball-test.tar.gz | fold -w 80 -s > output.txt
I used GNU tar
for this example, but one of the incantations above should work with other tar
implementations.
In fold
note that the -s
option breaks at spaces - if they exist. See this Q&A for alternatives & options to fold
.
You can test this by creating some files & making a tarball:
$ for i in {1..25}; do printf 'file1' >> file1.txt; done
$ for i in {1..30}; do printf 'xxfile2' >> file2.txt; done
$ for i in {1..20}; do printf 'file3 ' >> file3.txt; done
$ tar -czf tarball-test.tar.gz file1.txt file2.txt file3.txt
Note that the files created above contain no line breaks. This is unusual, but I didn't want to make assumptions re the OP's files. However, usage of such (non-delimited) files makes the behavior of fold
undefined. Otherwise, to avoid this risk, create the files with line breaks as shown below.
$ for i in {1..25}; do printf 'file1' >> file1.txt; done; printf '\n' >> file1.txt
$ for i in {1..30}; do printf 'xxfile2' >> file2.txt; done; printf '\n' >> file2.txt
$ for i in {1..20}; do printf 'file3 ' >> file3.txt; done; printf '\n' >> file3.txt
$ tar -czf tarball-test.tar.gz file1.txt file2.txt file3.txt
base64
the tarball by yourself, the recipient will need tobase64 -d
it by hand. E-mail clients do this automatically with actual attachments and it works. Do not unpack the tarball beforehand because it takes care of names and boundaries of the files within, let the recipient do this. So the easiest way is just to attach the tarball. What problem are you trying to solve by willing to invent another way? – Kamil Maciorowski Dec 23 '23 at 09:14uuencode
and friends? – Chris Davies Dec 23 '23 at 17:51