In my bash command line, when I use unzip -l test.zip
I get the output like this:
Archive: test.zip
Length Date Time Name
--------- ---------- ----- ----
810000 05-07-2014 15:09 file1.txt
810000 05-07-2014 15:09 file2.txt
810000 05-07-2014 15:09 file3.txt
--------- -------
2430000 3 files
But I am interested only by the lines containing the file details.
I tried to make filtering using grep like this:
unzip -l test.zip | grep -v Length | grep -v "\-\-\-\-" | g -v Archive | grep -v " files"
But it is long and prone to error (e.g a file name Archive in this list will be dropped)
Is there any other options with unzip -l (I checked the unzip man page and did not find any) or another tool to do so?
It is important to me to not really unzip the archive but just to look what files are inside.
grep
can be refactored into an Awk script, usually with much improved precision.awk 'NR >3 { if (/^ *---/) exit 0; print }'
would trim the first three lines as well as the footer, and also be within reach of easily extracting just the file name (hint:print substr($0, 29)
).