从 STDIN 读取数据时压缩文件 [英] Compress files while reading data from STDIN

查看:41
本文介绍了从 STDIN 读取数据时压缩文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Linux 上从 stdin 读取时是否可以压缩(创建压缩存档)数据?

Is it possible to compress (create a compressed archive) data while reading from stdin on Linux?

推荐答案

是的,为此使用 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 | gzip > test.csv.gz

cat test.csv 将数据作为标准输出发送,使用管道符号 gzip 将数据作为标准输入读取.确保将 gzip 输出重定向到某个文件,因为压缩数据不会写入终端.

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.

这篇关于从 STDIN 读取数据时压缩文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆