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 09-19-2004, 01:18 PM   #1
Henster
Member
 
Registered: Jul 2004
Posts: 45

Rep: Reputation: 15
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
 
Old 09-19-2004, 02:05 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
ls -1 *zip | xargs -xl unzip


Cheers,
Tink

Last edited by Tinkster; 09-19-2004 at 02:20 PM.
 
Old 09-19-2004, 02:07 PM   #3
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
Why wouldn't it just work to pipe it to unzip - why must it be xarg'ed?
 
Old 09-19-2004, 02:21 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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
 
Old 09-19-2004, 02:35 PM   #5
Henster
Member
 
Registered: Jul 2004
Posts: 45

Original Poster
Rep: Reputation: 15
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
 
Old 09-19-2004, 02:49 PM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
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.

Last edited by jschiwal; 09-19-2004 at 02:55 PM.
 
Old 09-19-2004, 02:53 PM   #7
dsegel
Member
 
Registered: Aug 2004
Location: Davis, California
Distribution: Gentoo, always Gentoo.
Posts: 159

Rep: Reputation: 30
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.
 
Old 09-19-2004, 03:19 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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
 
Old 09-19-2004, 03:25 PM   #9
Henster
Member
 
Registered: Jul 2004
Posts: 45

Original Poster
Rep: Reputation: 15
ah. didnt know about that "-1" flag....

Cheers
H
 
Old 09-19-2004, 06:10 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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
 
  


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 Jmcatch742 Linux - Software 4 08-01-2004 12:52 PM
how do you unzip something slacker2007 Linux - Newbie 2 08-01-2004 11:19 AM
Unzip PhuckFonix Linux - Newbie 1 05-30-2004 08:10 PM
unzip thanko Linux - Software 13 05-02-2003 05:16 AM
Unzip? lintadsl Linux - General 6 12-01-2002 04:17 PM


All times are GMT -5. The time now is 10:56 PM.

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