Solved

Processing a list of files

Posted on 2011-09-19
6
166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

705 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