Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have multiple zip files inside a directory. In which I want the list of files inside each zip file. I dot want to extract them in the folder.

presently I am able to extract them, after that only I can get the file names. But I don't want to extract the zip files as there is space constraint on the system. Please advice.

share|improve this question

migrated from stackoverflow.com Nov 1 '12 at 12:26

This question came from our site for professional and enthusiast programmers.

    
What language are you using? Are you just want to command this in SSH? –  TheBlackBenzKid Oct 31 '12 at 11:26
    
yes in ssh only –  shekhar Oct 31 '12 at 18:00
add comment

2 Answers 2

up vote 2 down vote accepted

Since you have multiple files, then in order to unzip -l all of them, you need to pass a quoted wildcard to the unzip tool, or else the shell will expand the wildcard and unzip will receive multiple filenames. So you need to:

unzip -l "*.zip"

The "*.zip" part makes sure that unzip actually receives the * character intact.

share|improve this answer
    
Thanks it worked!! now what if i want to use logsave to save the output of this listing to any log file. –  shekhar Oct 31 '12 at 11:27
    
You simply redirect the output: unzip -l "*.zip" >> logfile.log This will append the output to logfile.log. If instead you want to overwrite rather than append, use > instead of >>. –  Nikos C. Oct 31 '12 at 11:30
add comment
unzip -l {myzipfile}

will just report the contents (filenames)

share|improve this answer
    
thanks For the prompt reply but i am not able to get any result :( –  shekhar Oct 31 '12 at 11:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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