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.
bashunzip -l yourfile.zip | awk 'NR==3 {while (getline) {if ($2 == "--") break; print $4}}'
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 (--).If you want a simpler approach and don't mind seeing the header lines, you can use:
bashunzip -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.
Vibe can make mistakes. Check answers. Learn more