在Powershell中,如何分割一个大的二进制文件?
我已经在其他地方看到了文本文件的答案,但我需要对压缩文件执行此操作。
我有一个 6G 的二进制文件,需要分成 100M 的块。我是否在某处错过了unix“头”的模拟?
I've seen the answer elsewhere for text files, but I need to do this for a compressed file.
I've got a 6G binary file which needs to be split into 100M chunks. Am I missing the analog for unix's "head" somewhere?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没关系。在这里:
假设:bufSize 适合内存。
Never mind. Here you go:
Assumption: bufSize fits in memory.
必然问题的答案:如何将它们重新组合在一起?
The answer to the corollary question: How do you put them back together?
我回答了 bernd_k 在这个问题的评论中提到的问题,但在这种情况下我会使用 -
ReadCount
而不是-TotalCount
例如,这会导致
Get-Content
code> 一次读取文件的一个块,其中块大小要么是文本编码的行,要么是字节编码的字节。请记住,当它执行此操作时,您会得到一个沿着管道传递的数组,而不是单个字节或文本行。I answered the question alluded to in this question's comments by bernd_k but I would use -
ReadCount
in this case instead of-TotalCount
e.g.This causes
Get-Content
to read a chunk of the file at a time where the chunk size is either a line for text encodings or a byte for byte encoding. Keep in mind that when it does this, you get an array passed down the pipeline and not individual bytes or lines of text.