Solved

Processing a list of files

Posted on 2011-09-19
6
162 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Utilizing an array to gracefully append to a list of EmailAddresses
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now