Unzipping latest zip file by name.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unzipping latest zip file by name.
# 1  
Old 08-07-2009
Unzipping latest zip file by name.

I have these zip files that come in with the same name, but different versions. We'll say:

SQL_version2.zip
SQL_version3.zip
SQL_version2432.zip

I was wondering if there is a single command (or even piped command, thus still making it a single command) that will let me unzip the latest version only? In this case, I'd want to unzip SQL_version2432.zip only.

Thanks in advance.
# 2  
Old 08-07-2009
ls -lrt | tail -1 | awk '{print $9}'|xargs unzip
# 3  
Old 08-07-2009
Code:
unzip $(ls -1t | head -1)

# 4  
Old 08-07-2009
I think I got it.

I can't use the "t" flag on the ls because the creation/modification dates won't sync up with the order of the zip file versions. Thanks though. I think I've got it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can we Zip multiple files created on the same date into one single zip file.?

Hi all i am very new to shell scripting and need some help from you to learn 1)i have some log files that gets generated on daily basis example: i have abc_2017_01_30_1.log ,2017_01_30_2.log like wise so i want to zip this 4 logs which are created on same date into one zip folder. 2)Post zipping... (1 Reply)
Discussion started by: b.saipriyanka
1 Replies

2. UNIX for Beginners Questions & Answers

How can we Zip multiple files created on the same date into one single zip file.?

Hi all i am very new to shell scripting and need some help from you to learn 1)i have some log files that gets generated on daily basis example: i have abc_2017_01_30_1.log ,2017_01_30_2.log like wise so i want to zip this 4 logs which are created on same date into one zip folder. 2)Post zipping... (2 Replies)
Discussion started by: b.saipriyanka
2 Replies

3. UNIX for Dummies Questions & Answers

Print Only File Name in Zip File With out Unzipping It

How i print just only the file name in the zip file. unzip -l AAC_20130930_v13.xml.zip Archive: AAC_20130930_v13.xml.zip Length Date Time Name -------- ---- ---- ---- 62665745 11-19-13 10:43 AAC_20130930_v13.xml -------- ------- 62665745 ... (2 Replies)
Discussion started by: Ariean
2 Replies

4. Shell Programming and Scripting

Script to move latest zip file to another directory

Hi folks, In my application there is a job running which create a .dat file along with it zip file also at unix box location /opt/app/cvf/temp1 so in temp1 directory I have one .dat file and its zip file also. Now since this job runs every day so if a job runs today there will be two files... (5 Replies)
Discussion started by: punpun66
5 Replies

5. Shell Programming and Scripting

Zip Multiple files to One .zip file in AIX system

Hi I have a requirement in unix shell where I need to zip multiple files on server to one single .zip file. I dont see zip command in AIX and gzip command not doing completely what I want. One I do .zip file, I should be able to unzip in my local Computer. Here is example what I want... (9 Replies)
Discussion started by: RAMA PULI
9 Replies

6. Shell Programming and Scripting

Finding a text file from a group of zip files without unzipping

HI , There are more than 100 zip files in a directory and i wanted to see if there is a max1157.txt file in any of the zip files without actually unzipping them. Could you please help. Thanks in Advance. Karthik. (6 Replies)
Discussion started by: karthikk0508
6 Replies

7. UNIX for Dummies Questions & Answers

Unzipping windows zip files on Sun sparc workstation

I've got to install and compile some C++ source code that has been developed on a windows box on a Sun sparc workstation. Can I simply e-mail myself some windows zip files and then download and unzip them on the sparc box? I've tried this on a linux openSUSE machine and it works fine but I'm not... (4 Replies)
Discussion started by: achartley
4 Replies

8. Solaris

Alter zip file without unzipping

I have some zip files. Every file has a "folder/xml file" inside it. Is there any way to change these zip files directly without unzipping them. I want to convert these zip files to "/xml file" (want to move the xml file/s one root up by removing the folder inside it.) Ex: -bash-3.00$ for file... (1 Reply)
Discussion started by: _prasad
1 Replies

9. UNIX for Dummies Questions & Answers

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... (5 Replies)
Discussion started by: oracledev
5 Replies

10. UNIX for Dummies Questions & Answers

unzipping .zip file on HP and Solaris

I am transferring a large .zip file (20 GB) from an NT server to HP-UX and Solaris servers. Originally I tried to use info-zip's unzip, but I found out pretty quickly that it does not support files over 4GB. Any suggestions on how to work around this problem? Different decompression utility?... (9 Replies)
Discussion started by: dangral
9 Replies
Login or Register to Ask a Question