powershell 获取文件的第一个 x MB [英] powershell to get the first x MB of a file

查看:28
本文介绍了powershell 获取文件的第一个 x MB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获取文本文件的前 x 行非常简单,但我需要文件的前 x MB.鉴于我是 PowerShell 新手,如果您能在脚本上给我一些注释,我将不胜感激.

Its pretty straightforward to get the first x lines of a text file, but I need the first x MB of a file. Given that I'm a PowerShell neophyte if you could please give me some annotations on the script that would be greatly appreciated.

推荐答案

Get-Content foo.exe -TotalCount 1MB -Encoding byte

如果您碰巧正在使用 PowerShell 社区扩展,请执行以下操作:

If you happen to be using PowerShell Community Extensions then do this:

Format-Hex foo.exe -count 1MB

注意:如果您使用的是 PowerShell V2,请务必获取 PSCX 的 1.2 测试版.

Note: If you are using PowerShell V2 be sure to grab the 1.2 beta of PSCX.

这篇关于powershell 获取文件的第一个 x MB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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