I have a very large file as: filename.bz2
, how can I view the file content and do some commands like awk
to extract some data into another file without decompress it ? I tried head -50 filename.bz2
to view the first 50 lines, but it prints out rubbish and not the what I supposed to view from the file.
我有一个非常大的文件:filename.bz2,如何查看文件内容并执行一些命令如awk将一些数据提取到另一个文件而不解压缩?我尝试使用-50 filename.bz2来查看前50行,但它打印出垃圾而不是我应该从文件中查看的内容。
2 个解决方案
#1
14
You can use bzcat
and pipe its output to awk
or whatever tool you use, but it is essentially nothing different from extracting a file and then processing it.
您可以使用bzcat并将其输出管道输出到awk或您使用的任何工具,但它与提取文件然后处理它本质上没什么不同。
$ echo '1' > test
$ bzip2 test
$ bzcat test.bz2
1
#1
14
You can use bzcat
and pipe its output to awk
or whatever tool you use, but it is essentially nothing different from extracting a file and then processing it.
您可以使用bzcat并将其输出管道输出到awk或您使用的任何工具,但它与提取文件然后处理它本质上没什么不同。
$ echo '1' > test
$ bzip2 test
$ bzcat test.bz2
1