LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 03-09-2011, 12:34 PM   #1
dougp23
Member
 
Registered: Oct 2006
Posts: 36

Rep: Reputation: 15
BASH Unzip (and Search) Many Files in Directories


Our email system does a backup each day of all email sent and received, and stores it in a directory with the date stamp, so:

mail/2010-10-10/2010-10-10.zip
mail/2010-10-11/2010-10-11.zip
mail/2010-10-12/2010-10-12.zip

etc

I now have to provide all emails from jsmith@whatver.com from 2010-10-01 to 2010-12-31. Of course, this is impossible to do until I unzip everything!

There has got to be a way to automate this! I am thinking some sort of bash script would walk through all the directories unzipping as it went, then I could use egrep or something for what i am looking for.

Appreciate any help!
 
Old 03-09-2011, 12:36 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Distribution: Arch 2014.02.01
Posts: 2,309
Blog Entries: 1

Rep: Reputation: 740Reputation: 740Reputation: 740Reputation: 740Reputation: 740Reputation: 740Reputation: 740
Do you have to keep the unzipped files in the dated directories? Or can the unzipped files be lumped into one directory together?
 
Old 03-09-2011, 12:41 PM   #3
dougp23
Member
 
Registered: Oct 2006
Posts: 36

Original Poster
Rep: Reputation: 15
Nope, it could all be unzipped into one big directory! I'm not fussy, lol!
 
Old 03-09-2011, 01:20 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Distribution: Arch 2014.02.01
Posts: 2,309
Blog Entries: 1

Rep: Reputation: 740Reputation: 740Reputation: 740Reputation: 740Reputation: 740Reputation: 740Reputation: 740
Code:
cd /mail/directory/; find . -name \*.zip -exec unzip {} -d /some/directory/to/unzip/to/ \;
 
1 members found this post helpful.
Old 03-09-2011, 01:45 PM   #5
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,360

Rep: Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909
What about zipgrep? It is a shell script usually provided by the unzip package that does exactly what you're looking for, using unzip and egrep.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH: Unzip files/folders from archive one at a time using a loop cade Programming 3 05-16-2010 10:48 PM
Search repo for files/directories by name with wget gnashley Programming 1 12-30-2007 05:13 AM
Bash script to search through directories. mcdrr Programming 5 05-11-2007 05:41 PM
How to search all directories for a file in bash overlook1977 Linux - Newbie 7 04-10-2007 07:00 AM
Search for files only in directories you have sufficient permissions tepez Linux - Software 1 04-08-2007 10:07 AM


All times are GMT -5. The time now is 08:04 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration