How on Linux list not recursively files in .zip?
Nov 15, 6:47pm

To list the files inside a .zip archive non-recursively (i.e., only the files and directories at the root of the archive) on Linux, you can use the unzip command with the -l (list) option and filter the output to show only the root-level entries.

Command:

bash
unzip -l yourfile.zip | awk 'NR==3 {while (getline) {if ($2 == "--") break; print $4}}'

Explanation:

  • unzip -l yourfile.zip: Lists all files in the archive.
  • awk 'NR==3 {while (getline) {if ($2 == "--") break; print $4}}': Skips the header lines and prints only the filenames (the 4th field) until it encounters the separator line (--).

Alternative (simpler):

If you want a simpler approach and don't mind seeing the header lines, you can use:

bash
unzip -l yourfile.zip | head -n -1 | tail -n +4 | awk '{print $4}'

This will list only the root-level files and directories in the .zip archive.

Nov 15, 6:47pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more