Unix/Linux Go Back    


UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

unzip .zip file and list the files included in the .zip archive

UNIX for Dummies Questions & Answers


 
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 04-08-2008   -   Original Discussion by oracledev
oracledev's Unix or Linux Image
oracledev oracledev is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 8 April 2008, 5:47 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
unzip .zip file and list the files included in the .zip archive

Hello,
I am trying to return the name of the resulting file from a .zip archive file using unix unzip command.

unzip c07212007.cef7081.zip
Archive: c07212007.cef7081.zip
SecureZIP for z/OS by PKWARE
inflating: CEP/CEM7080/PPVBILL/PASS/G0063V00

I used the following command to unzip in quite mode (-q), without making directories(-j) and overwrite existing files(-o)

unzip - qjo c07212007.cef7081.zip

The above cmd unzippes the file "G0063V00" in the current working directory.

In addition to unzipping the file in the current working dir, I would like to store the filename resulting filename "G0063V00" in a variable for further processing. How do I get the filename that was just unzipped ? I tried using -l option but I get a lot more information than needed.

unzip -qjol c07212007.cef7081.zip

Length Date Time Name
-------- ---- ---- ----
265 07-22-07 03:32 CEP/CEM7080/PPVBILL/PASS/G0063V00
-------- -------
265 1 file

So I tried the following:

basename "`unzip -qojl c07212007.cef7081.zip`"

G0063V00
-------- -------
265 1 file


As you see, I still get more information than I need. I just want to return the filename which in this case is "G0063V00".

Thanks for you help in advance.
Sponsored Links
    #2  
Old Unix and Linux 04-08-2008   -   Original Discussion by oracledev
pupp's Unix or Linux Image
pupp pupp is offline Forum Advisor  
cap_10hdx 1
 
Join Date: Feb 2008
Last Activity: 22 September 2010, 2:56 PM EDT
Location: Jersey Shore
Posts: 647
Thanks: 0
Thanked 0 Times in 0 Posts
you could sort by last modified, grab first entry into variable then echo out the variable.
Sponsored Links
    #3  
Old Unix and Linux 04-08-2008   -   Original Discussion by oracledev
oracledev's Unix or Linux Image
oracledev oracledev is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 8 April 2008, 5:47 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
There are other processes concurrently creating files in the same directory.
    #4  
Old Unix and Linux 04-08-2008   -   Original Discussion by oracledev
era's Unix or Linux Image
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
 
Join Date: Mar 2008
Last Activity: 28 March 2011, 6:41 AM EDT
Location: /there/is/only/bin/sh
Posts: 3,653
Thanks: 0
Thanked 11 Times in 9 Posts


Code:
basename "`unzip -qojl c07212007.cef7081.zip | awk 'NR==3{print $4}'`"

maybe?
Sponsored Links
    #5  
Old Unix and Linux 04-08-2008   -   Original Discussion by oracledev
oracledev's Unix or Linux Image
oracledev oracledev is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 8 April 2008, 5:47 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks ! That did the trick.

If you dont mind, can you briefly explain
awk 'NR==3{print $4}'

Thanks for you help !
Sponsored Links
    #6  
Old Unix and Linux 04-08-2008   -   Original Discussion by oracledev
era's Unix or Linux Image
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
 
Join Date: Mar 2008
Last Activity: 28 March 2011, 6:41 AM EDT
Location: /there/is/only/bin/sh
Posts: 3,653
Thanks: 0
Thanked 11 Times in 9 Posts
Fourth field of third line. See the awk manual page or any introductory Unix book for details.
Sponsored Links
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Zip a list of specific files to an archive Biggreuda Shell Programming and Scripting 3 04-24-2012 06:45 AM
How to Unzip a file using unzip utility for files zipped without zip utility ? Sabari Nath S Shell Programming and Scripting 1 12-11-2009 05:18 PM
unzip few files but with same path and file name. jimmy_y Shell Programming and Scripting 1 08-27-2009 11:20 PM
Unzip selected files in .tar.gz file trongkhuongsg Linux 1 05-05-2009 03:38 PM
read list of filenames from text file, archive, and remove fxvisions Shell Programming and Scripting 5 03-20-2007 09:56 PM



All times are GMT -4. The time now is 01:56 PM.