LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-16-2010, 05:22 PM   #1
cade
LQ Newbie
 
Registered: May 2010
Posts: 3

Rep: Reputation: 0
BASH: Unzip files/folders from archive one at a time using a loop


Hi, I am relatively new to programming and I need some help with my script.
I need to use a loop to unzip files and folders one at a time from a zip archive.

Something like this would be nice:
Code:
#!/bin/sh
archive=/path/to/file.zip
num=somehowgetthenumberofitemsinarchive
for*((*i=0;i<$num;i++));*do
unzip #insert magic here
echo "Progress = $((i/num*100))%"
done
Help would be appreciated
 
Old 05-16-2010, 07:34 PM   #2
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Code:
find /path/to/zipfolder -name '*.zip' -exec unzip '{}' /;
will unzip all files with zip-suffix in /path/to/zipfolder and its subfolders.
 
Old 05-16-2010, 09:22 PM   #3
cade
LQ Newbie
 
Registered: May 2010
Posts: 3

Original Poster
Rep: Reputation: 0
I meant I want to take items out of a single zip file one at a time.
 
Old 05-16-2010, 10:48 PM   #4
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Quote:
Originally Posted by cade View Post
I meant I want to take items out of a single zip file one at a time.
In that case
Code:
man unzip
has all you need for that. There is no need to create a loop.
 
  


Reply

Tags
bash, loop, unzip



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
[SOLVED] BASH Question: Using a loop to download a series of files roystonlodge Programming 2 02-02-2010 02:18 PM
Loop through all files in a directory. Bash/Perl script? Nzo Linux - Newbie 9 12-09-2009 07:09 PM
Can drakbackup archive the different folders, with separate archiving files? bistra Mandriva 5 02-18-2008 09:28 AM
about unzip to unzip some chinese files' trouble arcow Linux - Software 0 03-24-2006 02:25 AM
How to unzip files recursively inside folders? jessdog9001 Linux - Software 2 03-22-2006 12:59 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:57 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
Open Source Consulting | Domain Registration