I need to get the root directories of a compound file on a linux system. For this, i tried to use 7zip (p7zip-full) since this tool can read the compound file format.

This basically works great, but it outputs an horrible parsable text.


So my question to the community is, is there a chance to get this output parsed nicely to get an output like:

  • IPC_0805_CHIP_CAP
  • FileHeader
  • Library
  • ZForm
  • DO-214AA
  • ...


I need this information inside of a php script. so at the end, the command will be executed from a php script. If there is any chance to read the compound file structure directly with php, this would be highly appreciated.



That's some output there, and 7z doesn't seem to have much in the way of format options. I wouldn't want to try just grep, but a combination of head, tail & cut should work well enough to output just the filenames, and similar cuts should work for the other info, tee and process substitution ( <() ) could help. Or just cut each line by characters with php (I'm not familiar enough with it).

With my 7zr version, it has 18 lines of non-filename info at the start, and 2 lines at the end, with each line having 54 non-filename characters at the start, adjust if yours is different:

$ 7zr l test.7z  |tail -n+18|head -n-2|cut -c54-
  • Works like a charm! Thank you very much!! – C. Hediger Mar 21 '17 at 11:00

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.