Solved

Processing a list of files

Posted on 2011-09-19
6
163 Views
Last Modified: 2012-08-14
I have a files that contains a list of other files  i.e

MyZipFiles

/home/temp/1.zip
/home/temp/2.zip

How would would a write a script to interate over the files in this list and unzip them. I want pass the the fileName (MyZipFiles) into my script

0
Comment
Question by:Molko
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:jmsloan
ID: 36561749
this line will llist all file if the filename exist in MyZipFile

for line in `cat MyZipFile`; do  echo $line; done
0
 

Author Comment

by:Molko
ID: 36561759
so where you have

do echo $line;

I can have my unzip $line

?
0
 
LVL 3

Expert Comment

by:jmsloan
ID: 36561766
for line in `ls *.zip`; do  unzip $line; done
0
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
LVL 3

Expert Comment

by:jmsloan
ID: 36561792
Yes assuming you have unzip installed.

If file list is stored in a file
for line in `cat MyZipFile`; do  unzip $line; done

If you want to list all .zip file
for line in `ls *.zip`; do  unzip $line; done
0
 
LVL 23

Accepted Solution

by:
Kamaraj Subramanian earned 500 total points
ID: 36564551
while read filename
do
     unzip $filename && echo "$filename unzipped" || echo "Problem in unzipping - $filename"
done < MyZipFiles

Open in new window

0
 

Author Closing Comment

by:Molko
ID: 36911997
ta !
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question