LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-28-2008, 07:34 AM   #1
eltnux
LQ Newbie
 
Registered: Nov 2007
Posts: 4

Rep: Reputation: 0
Scritping - Point in the right direction


I'm completely new to writing scripts in Linux and wish to wright a script to look through a directory and i'ts subdirectories and when it finds a zip file check the integrity of this file.

I done a bit of investigation and know that i need to use

Code:
zip -T filename.zip
to test the integrity of the file, but i not sure how to recursively work my way through a directory structure. Each directory may have zero or more zip files and zero or more directories.

I'm not asking for the script to be written just some pointers in the right direction.

Thanks for any help.
 
Old 01-28-2008, 07:49 AM   #2
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 71
The find command searches directories recursively. Something like this

find . -name \*.zip -exec zip -T \{\} \;

should work for you.
 
Old 01-28-2008, 08:12 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by Uncle_Theodore View Post
find . -name \*.zip -exec zip -T \{\} \;
should work for you.
...unless path elements include spaces. Then you'd use find with "-print0" and xargs with "-0:.
 
Old 01-28-2008, 10:20 AM   #4
eltnux
LQ Newbie
 
Registered: Nov 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
...unless path elements include spaces. Then you'd use find with "-print0" and xargs with "-0:.
Am i right in thinking i would need, as the directories and file name containe spaces.

Code:
find . -name -print0 \*.zip | xargs -0 zip -T \{\} \;
 
Old 01-29-2008, 04:52 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
You are right in thinking that is what you need.
 
Old 01-30-2008, 02:00 PM   #6
eltnux
LQ Newbie
 
Registered: Nov 2007
Posts: 4

Original Poster
Rep: Reputation: 0
I had to change the code to

Code:
find . -print0 -name \*.zip | xargs -0 zip -T \{\} \; > zip.txt
as the previous version failed as the -name argument was expecting a directory next not another argument.

Thanks for all your help.

Last edited by eltnux; 01-30-2008 at 02:15 PM.
 
  


Reply



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
can someone point me in the right direction so i dont mess it up aeiouer Linux - Laptop and Netbook 13 06-05-2007 10:45 PM
Can anyone point me in the right direction to install Azureus on 10.0? A6Quattro SUSE / openSUSE 2 10-14-2005 09:05 AM
Point me in the right direction amnesty_puppy Linux - Networking 2 01-02-2005 11:57 AM
Can someone point me in the right direction? Desai Linux - Networking 4 09-22-2004 08:25 AM
Please.. point me in the right direction tw001_tw Linux - Newbie 3 05-03-2004 04:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:43 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