LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-09-2009, 05:33 AM   #1
SanaJay
LQ Newbie
 
Registered: Jan 2009
Posts: 6

Rep: Reputation: 0
Help to unzip more than one *.zip files


Hi,
I need to unzip more than one abc_*.zip files.
one file is
abc_ooo_<datetime>_<number>.zip and other file is
abc_ddd_<datetime>_<number>.zip

I tried this in the script

file_name=abc_*.zip
for -f $file_name{
unzip -o $file_name
}

But the files are not unzipped.I get this
"caution: filename not matched:abc_ooo_<datetime>_<number>.zip"

When i try to unzip single file,unzip works.

Please help to do this.

Thanks,
Sana
 
Old 02-09-2009, 05:40 AM   #2
SanaJay
LQ Newbie
 
Registered: Jan 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Updated-

sorry..the for loop I tried is as below:

file_name=abc_*.zip
for f in $file_name{
unzip -o $file_name
}

Thanks,
Sana
 
Old 02-09-2009, 05:47 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
I'd try to use double quotes to embed the filename. This should take care of spaces in filenames (if any). Also, the error is that you don't use the loop variable in the unzip command, but the whole file list. So try this:
Code:
for f in abc_*.zip 
do
  unzip -o "$f"
done
 
Old 02-09-2009, 05:52 AM   #4
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

Rep: Reputation: Disabled
Do you really need a script? unzip can take more than one file name as options.
 
Old 02-09-2009, 06:00 AM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Quote:
Originally Posted by linuxlover.chaitanya View Post
Do you really need a script? unzip can take more than one file name as options.
Not really. Only the first argument is the name of the archive to extract. Any further argument is the name(s) of the file(s) to extract from the archive. The error message explains it:
Code:
caution: filename not matched:abc_ooo_<datetime>_<number>.zip
since the OP gave the whole list of zip files as argument, unzip tries to extract a file called as the second archive from the first archive, but obviously there is not a matching filename inside the first archive!
 
Old 02-10-2009, 12:31 AM   #6
SanaJay
LQ Newbie
 
Registered: Jan 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks a lot.I was able to unzip the files.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
unzip all .zip files in a directory tes15 Linux - Newbie 14 08-29-2014 11:46 AM
Unzip multiple zip files, each to separate folder smart_sagittari Linux - Newbie 3 03-21-2012 08:41 AM
Need help to unzip a .zip file with 2 files in it SanaJay Linux - Newbie 3 02-05-2009 02:43 AM
How to Unzip 2 Zip files through one single command sumitarun Linux - Newbie 2 03-23-2005 08:00 AM
how do i unzip a .zip? lax2sman Linux - General 2 02-11-2002 05:17 PM


All times are GMT -5. The time now is 08:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration