LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using tar to exlude sertain date patterns in a directory (https://www.linuxquestions.org/questions/linux-newbie-8/using-tar-to-exlude-sertain-date-patterns-in-a-directory-777938/)

gubbu 12-24-2009 04:07 PM

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

GooseYArd 12-24-2009 07:15 PM

Quote:

Originally Posted by gubbu (Post 3803846)
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

gubbu 12-28-2009 02:23 PM

thanks. That totally helped


All times are GMT -5. The time now is 06:14 PM.