Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compress files while reading data from STDIN

People also ask

Can you pipe to gzip?

Yes, use gzip for this. The best way is to read data as input and redirect the compressed to output file i.e. cat test. csv will send the data as stdout and using pipe-sign gzip will read that data as stdin.

How do I gzip in stdout?

You need to pass the -c or --stdout , or --to-stdout option to the gzip command. This option specifies that output will go to the standard output stream, leaving original files intact.

What is ZCAT used for?

The zcat command allows the user to expand and view a compressed file without uncompressing that file. The zcat command does not rename the expanded file or remove the . Z extension. The zcat command writes the expanded output to standard output.


Yes, use gzip for this. The best way is to read data as input and redirect the compressed to output file i.e.

cat test.csv | gzip > test.csv.gz

cat test.csv will send the data as stdout and using pipe-sign gzip will read that data as stdin. Make sure to redirect the gzip output to some file as compressed data will not be written to the terminal.


Yes, gzip will let you do this. If you simply run gzip > foo.gz, it will compress STDIN to the file foo.gz. You can also pipe data into it, like some_command | gzip > foo.gz.


gzip > stdin.gz perhaps? Otherwise, you need to flesh out your question.