Linux shell命令按块读取/打印文件块 [英] Linux shell command to read/print file chunk by chunk

查看:132
本文介绍了Linux shell命令按块读取/打印文件块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个标准的Linux命令,我可以用块来读取文件块?
例如,我有一个大小为6kB的文件。我想读/打印第一个1kB,然后第二个1kB ...
似乎猫/头/尾不会工作在这种情况下。



谢谢非常多。

解决方案

dd会这样做
$ b $ $ pre> dd if = your_file of = output_tmp_file bs = 1024 count = 1 skip = 0

然后对第二个块跳过= 1,依此类推。

然后你只需要读取output_tmp_file就可以得到块。


Is there a standard Linux command i can use to read a file chunk by chunk? For example, i have a file whose size is 6kB. I want to read/print the first 1kB, and then the 2nd 1kB ... Seems cat/head/tail wont work in this case.

Thanks very much.

解决方案

dd will do it

dd if=your_file of=output_tmp_file bs=1024 count=1 skip=0

And then skip=1 for the second chunk, and so on.

You then just need to read the output_tmp_file to get the chunk.

这篇关于Linux shell命令按块读取/打印文件块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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