LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help to unzip more than one *.zip files (https://www.linuxquestions.org/questions/linux-newbie-8/help-to-unzip-more-than-one-%2A-zip-files-703318/)

SanaJay 02-09-2009 05:33 AM

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

SanaJay 02-09-2009 05:40 AM

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

colucix 02-09-2009 05:47 AM

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


linuxlover.chaitanya 02-09-2009 05:52 AM

Do you really need a script? unzip can take more than one file name as options.

colucix 02-09-2009 06:00 AM

Quote:

Originally Posted by linuxlover.chaitanya (Post 3437033)
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!

SanaJay 02-10-2009 12:31 AM

Thanks a lot.I was able to unzip the files.


All times are GMT -5. The time now is 09:33 AM.