Read Contents of file inside xar file using the command line

1.4k views Asked by At

I am trying to read the contents of the file inside the xar file without extracting them using the command line.

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

1

There are 1 answers

0
YeaTheMans On

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. 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)