简体   繁体   English

使用命令行读取xar文件中的文件内容

[英]Read Contents of file inside xar file using the command line

I am trying to read the contents of the file inside the xar file without extracting them using the command line. 我试图在xar文件中读取文件的内容,而不使用命令行提取它们。

When I run the command, 当我运行命令时,

xar -tf filename.xar | grep -i 'info'

it list all the file that I am after. 它列出了我所追求的所有文件。

But when I try to read the contents of those file using, 但是当我尝试使用时读取这些文件的内容,

cat `xar -tf filename.xar | grep -i 'info'`

I get the error message saying cat: filename: No such file or directory 我收到错误消息说cat:filename:没有这样的文件或目录

You where on the right track but the problem is your using cat to try and read a file that hasn't been extracted from the archive. 您在正确的轨道上,但问题是您使用cat尝试读取尚未从存档中提取的文件。 You need to extract the archive first before you can read its contents. 您需要先读取存档,然后才能读取其内容。 Use this code which extracts the file then reads the 'Info' file: 使用此代码提取文件,然后读取“信息”文件:

xar -xf filename.xar; cat `xar -tf filename.xar | grep -i 'info'`

Hope this helps :D (u could add a code at the end to delete the added extracted files) 希望这会有所帮助:D(你可以在最后添加一个代码来删除添加的提取文件)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM