When I do unzip -l zipfilename
, I see
1295627 08-22-11 07:10 A.pdf 473980 08-22-11 07:10 B.pdf ...
I only want to see the filenames. I try this
unzip -l zipFilename | cut -f4 -d" "
but I don't think the delimiter is just " "
.
Also, you can use the zip command with the -sf option to view the contents of the . zip file. Additionally, you can view the list of files in the . zip archive using the unzip command with the -l option.
Right-click on the downloaded archive file and select Extract All... from the context-sensitive menu that displays. The Extract Compressed (Zipped) Folders dialog displays. Click Browse to navigate to the location where you want the files and directories that are contained in the archive to be extracted.
Right-click the file you want to zip, and then select Send to > Compressed (zipped) folder. Open File Explorer and find the zipped folder. To unzip the entire folder, right-click to select Extract All, and then follow the instructions. To unzip a single file or folder, double-click the zipped folder to open it.
What you need is ZipFile. namelist() that will give you a list of all the contents of the archive, you can then do a zip. open('filename_you_discover') to get the contents of that file.
The easiest way to do this is to use the following command:
unzip -Z -1 archive.zip
or
zipinfo -1 archive.zip
This will list only the file names, one on each line.
The two commands are exactly equivalent. The -Z
option tells unzip to treat the rest of the options as zipinfo options. See the man pages for unzip and zipinfo.
Assuming none of the files have spaces in names:
unzip -l filename.zip | awk '{print $NF}'
My unzip output has both a header and footer, so the awk script becomes:
unzip -l filename.zip | awk '/-----/ {p = ++p % 2; next} p {print $NF}'
A version that handles filenames with spaces:
unzip -l filename.zip | awk ' /----/ {p = ++p % 2; next} $NF == "Name" {pos = index($0,"Name")} p {print substr($0,pos)} '
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With