can someone tell me if is possible to directly compress stdout?
I would like to do this in one step without creating temporary file files.txt...
Example:
cat file* > files.txt
tar -czf files.tar files.txt
rm files.txt
Is this possible?
can someone tell me if is possible to directly compress stdout?
I would like to do this in one step without creating temporary file files.txt...
Example:
cat file* > files.txt
tar -czf files.tar files.txt
rm files.txt
Is this possible?
You can bypass the
tar
part of.tar.gz
in this case, since you don't need to handle multiple files, and skip straight togzip
for compression.To compress
To decompress
or equivalently
You can also use the
bzip2
andxz
compression utilities with similar syntax.xz
usually produces smaller compressed files than eithergzip
orbzip2
.(Footnote)
If you are creating a compressed file and then using
scp
to transfer it, you can use built-in compression:or
or
Leave the f option off.
Something I've done is like this:
This prints to stdout. I could then use some code to ssh into the server tar/gzip them all up and save locally without needing to create a new file on the server.