1

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

Ishan
  • 3,931
  • 11
  • 37
  • 59
  • If xar is like tar then the -t argument stands for test and it outputs a bunch of strings with one line for each file in the tar file. Grep gives you a subset of those names that contain 'info'. You need to actually get the files out of the tar by using -x argument instead. However, -x puts each file into a new file in your directory or subdirectories if the tar contains subdirectories. – Marichyasana Jun 11 '16 at 07:31
  • 1
    Try `xar -x -f filename.xar --to-stdout $(xar -tf filename.xar | grep -i 'info')` – Mark Plotnick Jun 11 '16 at 11:49
  • @MarkPlotnick Getting *xar: unrecognized option `--to-stdout`* – Ishan Jun 12 '16 at 03:39
  • @Marichyasana. The -t argument in the xar command lists the contents of the xar archive filename.xar – Ishan Jun 12 '16 at 03:43

1 Answers1

1

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)

YeaTheMans
  • 1,005
  • 8
  • 19