Solved

Processing a list of files

Posted on 2011-09-19
6
161 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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 …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

17 Experts available now in Live!

Get 1:1 Help Now