LinuxQuestions.org
Register a domain and help support LQ
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 12-24-2009, 05:07 PM   #1
gubbu
LQ Newbie
 
Registered: Dec 2009
Posts: 10

Rep: Reputation: 0
Using tar to exlude sertain date patterns in a directory


I have a directory with hundreds of files for example

rwxr-xr-x 1 app app 49 Oct 15 2008 a.zip
-rwxr-xr-x 1 app app 124 Oct 12 2009 b.zip
-rwxr-xr-x 1 app app 49 Oct 15 2008 c.zip
rwxr-xr-x 1 app app 49 Nov 15 2008 d.zip
-rwxr-xr-x 1 app app 124 Dec 15 2008 e.zip
-rwxr-xr-x 1 app app 49 Dec 15 2008 f.zip
rwxr-xr-x 1 app app 65252 Mar 3 2009 g.zip
-rwxr-xr-x 1 app app 32605 Mar 3 2009 h.zip

I want to create tar files for only "Oct" for 2008 ,"oct" for 2009,Dec 2009 etc

Basically my tar file will group files for each month
 
Old 12-24-2009, 08:15 PM   #2
GooseYArd
Member
 
Registered: Jul 2009
Location: Reston, VA
Distribution: Slackware, Ubuntu, RHEL
Posts: 183

Rep: Reputation: 46
Quote:
Originally Posted by gubbu View Post
I have a directory with hundreds of files for example

rwxr-xr-x 1 app app 49 Oct 15 2008 a.zip
-rwxr-xr-x 1 app app 124 Oct 12 2009 b.zip
-rwxr-xr-x 1 app app 49 Oct 15 2008 c.zip
rwxr-xr-x 1 app app 49 Nov 15 2008 d.zip
-rwxr-xr-x 1 app app 124 Dec 15 2008 e.zip
-rwxr-xr-x 1 app app 49 Dec 15 2008 f.zip
rwxr-xr-x 1 app app 65252 Mar 3 2009 g.zip
-rwxr-xr-x 1 app app 32605 Mar 3 2009 h.zip

I want to create tar files for only "Oct" for 2008 ,"oct" for 2009,Dec 2009 etc

Basically my tar file will group files for each month
ls -lR | grep Oct | grep 2009 | awk '{ print $9 }' | xargs tar cvzf october.tar.gz
 
Old 12-28-2009, 03:23 PM   #3
gubbu
LQ Newbie
 
Registered: Dec 2009
Posts: 10

Original Poster
Rep: Reputation: 0
thanks. That totally helped
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
selectively tar based on date just the innermost directories of a single directory rsiazon Linux - Newbie 5 07-29-2009 01:15 AM
Samba exlude files jo4 Linux - Server 0 11-18-2007 06:53 PM
what is the correct syntax order for tar with --after-date DATE, --newer DAT farhan Linux - General 1 03-16-2007 09:43 AM
Date Validation in java using Patterns Manashi Programming 2 07-31-2006 08:19 AM
Remembering patterns and printing only those patterns using sed bernie82 Programming 5 05-26-2005 06:18 PM


All times are GMT -5. The time now is 10:55 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration