tar files by date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting tar files by date
# 1  
Old 06-22-2010
tar files by date

Hi,

I have a solaris 10, I would like to tar log files by date, or by range of hours into one tar file.
All I coud do is by name (very simple...Smilie).
# 2  
Old 06-22-2010
lets say you have file names like

syslog.7
syslog.6
syslog.5
syslog.4
syslog.3
syslog.2
syslog.1
syslog.0
syslog

find command may help you here to find all files newer than a point of reference.

Code:
find . -newer syslog.1

will produce

./syslog
./syslog.0

and tar command can be utilized like

Code:
tar cvf archive.tar `find /absolute/path/ -new /absolute/path/file`

# 3  
Old 06-22-2010
Can you limit the search "from date to date"?
Let's say today is June 22nd and I wish to tar only June 21 files not including 20 and 22 Smilie
# 4  
Old 06-22-2010
Code:
find . -mtime 1

should list files only 1 day older.
# 5  
Old 06-22-2010
Code:
find . -mtime +120 -exec ls -l{}\;

all the files generated 120days before. like this u can do easily
and u can put dates also in pladce of 120
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tar with variable date in separate shell

Hi, I am trying to Zip a folder inside a shell script like below. It successfully taring but it only returns Null inside the variables. Searched a lot but no clue to finding the root cause. testno=1; date=20171128; DIR=/root/ sh -c 'cd $DIR; tar cvf "AWS.${testno.${date}.tar" "./AWS"' ... (5 Replies)
Discussion started by: pradyumnajpn10
5 Replies

2. Shell Programming and Scripting

How to list files that are not first two files date & last file date for every month-year?

Hi All, I need to find all files other than first two files dates & last file date for month and month/year wise list. lets say there are following files in directory Mar 19 2012 c.txt Mar 19 2012 cc.txt Mar 21 2012 d.txt Mar 22 2012 f.txt Mar 24 2012 h.txt Mar 25 2012 w.txt Feb 12... (2 Replies)
Discussion started by: Makarand Dodmis
2 Replies

3. Red Hat

Tar with particular date files

I need to find out only Jun 10 created and modified file with tar command ,, I am using Linux red hat x86_64 GNU/Linux. ls -lrt -rw-r--r-- 1 nova nova 2757 Jun 7 11:00 feed.ctl -rwxrwxr-x 1 nova nova 457 Jun 7 11:00 acc_feed.csh -rwxr-xr-x 1 nova nova 473 Jun 7 12:11... (2 Replies)
Discussion started by: balajikalai
2 Replies

4. Shell Programming and Scripting

Need help to tar and gzip files per date

hi, I have multiple files created per date every day. I want to be able to tar all the files older than 7 days into a single file and then gzip that tarred file and move it to a separate partition. Then delete the actual files. Eg - "ls -l" shows Dec 8 has 6-8 files created. I want to tar... (4 Replies)
Discussion started by: vishal7
4 Replies

5. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

6. UNIX for Dummies Questions & Answers

how to tar with date criteria?

I would like to tar (compress) all the files with some date criteria. I tried : tar -cvwf 20_08_2010.tar | ls -la | grep "Aug 20" but it's not working. How should I type? (3 Replies)
Discussion started by: bongo
3 Replies

7. UNIX for Advanced & Expert Users

How to create a Tar of multiple Files in Unix and FTP the tar to Windows.

Hi, On my Unix Server in my directory, I have 70 files distributed in the following directories (which have several other files too). These files include C Source Files, Shell Script Source Files, Binary Files, Object Files. a) /usr/users/oracle/bin b) /usr/users/oracle... (1 Reply)
Discussion started by: marconi
1 Replies

8. Shell Programming and Scripting

Sorting Files by date and moving files in date order

I need to build a k shell script that will sort files in a directory where files appear like this "XXXX_2008021213.DAT. I need to sort by date in the filename and then move files by individual date to a working folder. concatenate the files in the working folder then start a process once... (2 Replies)
Discussion started by: rebel64
2 Replies

9. UNIX for Advanced & Expert Users

Untaring *.tar.tar files

Hi all, How to untar a file with .tar.tar extension. A utility that i downloaded from net had this extension. Thanks in advance, bubeshj. (6 Replies)
Discussion started by: bubeshj
6 Replies

10. UNIX for Dummies Questions & Answers

tar archive: time, date?

Is there a way to know when (date, time) a tar archive on tape was created? (1 Reply)
Discussion started by: croy75
1 Replies
Login or Register to Ask a Question