LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   batch unzip (https://www.linuxquestions.org/questions/linux-newbie-8/batch-unzip-232570/)

Henster 09-19-2004 01:18 PM

batch unzip
 
Hi,

I'm trying to extract a whole bunch of zips with one command...

Maybe a collection of flags for "tar"? I cant seem to get it to work..

CHeers
H

Tinkster 09-19-2004 02:05 PM

ls -1 *zip | xargs -xl unzip


Cheers,
Tink

scuzzman 09-19-2004 02:07 PM

Why wouldn't it just work to pipe it to unzip - why must it be xarg'ed?

Tinkster 09-19-2004 02:21 PM

Quote:

Originally posted by scuzzman
Why wouldn't it just work to pipe it to unzip - why must it be xarg'ed?
What do you get when you try it?

My unzip comes back with a usage message.


Cheers,
Tink

Henster 09-19-2004 02:35 PM

I'm getting a usage message using the xargs version..
Unzip is trying to process these lines...


-rwxrwxr-x 1 root users 2993146 2004-09-08 07:50 ma551l02.zip
-rwxrwxr-x 1 root users 2993599 2004-09-08 07:53 ma551l03.zip
-rwxrwxr-x 1 root users 2994002 2004-09-08 07:55 ma551l04.zip
-rwxrwxr-x 1 root users 2993146 2004-09-08 07:57 ma551l05.zip
-rwxrwxr-x 1 root users 2993144 2004-09-08 07:59 ma551l06.zip
-rwxrwxr-x 1 root users 2993146 2004-09-08 08:01 ma551l07.zip

shouldnt it be...

ma551l02.zip
ma551l03.zip
ma551l04.zip
ma551l05.zip
ma551l06.zip
ma551l07.zip

help?

Cheers
H

jschiwal 09-19-2004 02:49 PM

I think the unzip arguments should be in uppercase. unzip -XL
You could create a quick loop in bash to unzip each file.

for zipfile in *.tar
do
unzip -XL "${zipfile}"
done

If you want to type it on one line:
for zipfile in *.tar; do unzip -XL "${zipfile}"; done

With bash, you can enter it in interactively as I did in the first version. The prompt will become '>' to let you know that you need to continue.

About your last question about including more zip files in the command line, additional files on the command line are taken as the particular files to extract from the zip archive rather than extracting them all.

About the unzip options, -X preserves the original owner and permission settings for linux files. -L converts names to lower case if the original files were saved on a FAT32 or similar filesystem where the filenames are uppercase.

The double quotes around the variable zipfile are needed in case the file name contains a whitespace or special character.

dsegel 09-19-2004 02:53 PM

Quote:

Originally posted by Henster
I'm getting a usage message using the xargs version..
Unzip is trying to process these lines...


-rwxrwxr-x 1 root users 2993146 2004-09-08 07:50 ma551l02.zip
-rwxrwxr-x 1 root users 2993599 2004-09-08 07:53 ma551l03.zip

It looks like you used 'ls -l' instead of 'ls -1'. IOW, you used a lowercase L instead of a one.

Tinkster 09-19-2004 03:19 PM

Quote:

Originally posted by dsegel
It looks like you used 'ls -l' instead of 'ls -1'. IOW, you used a lowercase L instead of a one.
Well spotted ;}

People should use copy & paste :}



Cheers,
Tink

Henster 09-19-2004 03:25 PM

ah. didnt know about that "-1" flag....

Cheers
H

Tinkster 09-19-2004 06:10 PM

Quote:

Originally posted by Henster
ah. didnt know about that "-1" flag....
No worries, we live and learn. (Learning about computers for
close to 30 years :})

Linux keeps you on your toes! :)


Cheers,
Tink


All times are GMT -5. The time now is 07:45 AM.