我有一个.bz2文件.我想列出第一行或最后10行而不解压缩,因为它太大了.我试过了head -10,tail -10但我看到了胡言乱语.我还需要比较两个压缩文件,以检查它们是否相似.如何在不解压缩文件的情况下实现这一目标?
编辑:类似意味着相同(具有相同的内容).
我目前正在尝试编写一个powershell函数,该函数与Lync powershell cmdlet"Export-CsConfiguration -AsBytes"的输出一起使用.使用Lync Cmdlet的隐式Powershell远程处理时,-AsBytes标志是使用Export-CsConfiguration cmdlet的唯一方法,它返回一个Byte数组,如果您使用"Set-Content -Encoding Byte"将其写入磁盘,结果是一个zip文件.
我想知道是否有办法将字节数组的内容扩展为包含在该zip文件中的两个文件,但只能在内存中进行.我真的不想保持zip文件很长时间,因为它经常更改,以及将文件内容写入磁盘只是为了再次直接读取它们所以我可以用未压缩的内容做一些看起来可怕的错误对我来说.
那么有没有做过这样的事情来避免写入磁盘:
$ZipFileBytes = Export-CsConfiguration -AsBytes
# Made up Powershell function follows:
[xml]DocItemSet = Extract-FileFromInMemoryZip -ByteArray $ZipFileBytes -FileInsideZipIWant "DocItemSet.xml"
# Do stuff with XML here
Run Code Online (Sandbox Code Playgroud)
而不是做:
$ZipFileBytes = Export-CsConfiguration -AsBytes | Set-Content -Encoding Byte "CsConfig.zip"
[System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
[System.IO.Compression.ZipFile]::ExtractToDirectory("CsConfig.zip", "C:\Temp")
[xml]$DocItemSet = New-Object Xml.XmlDocument
$DocItemSet.Load("C:\Temp\DocItemSet.xml")
# Do stuff with XML here
Run Code Online (Sandbox Code Playgroud)
或者我是SOL?
我如何在内联zcat 2 .gz文件中执行unix中的diff?尝试过eval但语法不对.
zcat file1.gz zcat file2.gz
Run Code Online (Sandbox Code Playgroud)