Archieve one weeks old txt files

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Archieve one weeks old txt files
# 1  
Archieve one weeks old txt files

Hi All,

Am trying to write a script which does the archiving of *.txt files if it's one week old from the current date.

File format :
-rw-r-----   1 root     root       20562 Sep 11 10:24 UQ-CI01_FF_20130905_10H24M.txt
-rw-r-----   1 root     root       20562 Sep 11 10:29 UQ-CI01_FF_20130906_10H29M.txt
-rw-r-----   1 root     root       20562 Sep 11 10:26 UQ-CI01_FF_20130907_10H26M.txt
-rw-r-----   1 root     root       20562 Sep 11 10:29 UQ-CI01_FF_20130908_10H29M.txt
-rw-r-----   1 root     root       20562 Sep 11 10:29 UQ-CI01_FF_20130909_10H29M.txt
-rw-r-----   1 root     root       20562 Sep 11 10:30 UQ-CI01_FF_20130910_10H30M.txt
-rw-r-----   1 root     root       20596 Sep 11 10:34 UQ-CI01_FF_20130911_10H34M.txt

from the above *.txt, script should archive UQ-CI01_FF_20130905_10H24M.txt file (by taring the file) only since it's week old file from current date and putting into Archive directory.

-rw-r-----   1 root     root       20562 Sep 11 10:24 UQ-CI01_FF_20130905_10H24M.tar.gz

Any help will be much apprecitated.

Many Thanks,
# 2  
Check this :

find /TK/Project_ATT/Archive/*.txt -type -mtime +7 | xargs tar zcvf /somelocation/backup.tgz

First command find get you list of files
2nd command creates a tar and gzips them.
# 3  
you can use something like below

find . -type f -name "*.txt" -mtime +7 -exec tar -zcvf UQ-CI01_FF_20130905_10H24M.tar {} \;

Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #238
Difficulty: Easy
Steve Jobs was the first to build a theoretical model for communication using packet switching.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare two txt files,mismatches will be in new txt files

Hi, Below are the sample data for txt files. txt file 1 Partnumber|catgroup_id 10001082|46016 10001093|4680 10001093|386003 10001093|463004 10003251|683 10003251|63005 10003252|463005 10003252|4683 10003260|463005 10003260|4683 10003264|4683 10003264|463005 13420000|67... (5 Replies)
Discussion started by: Ankita Talukdar
5 Replies

2. Shell Programming and Scripting

Move log files with date and delete older than 3 weeks

I have written a script which generate one logfile on every sunday and thursday I want to move the older log files into /tmp directory befor generating new one so i used mv command like mv usr/sbin/appl/logfile.txt usr/sbin/appl/tmp 2) But when i move this file to /tmp it will... (1 Reply)
Discussion started by: Nakul_sh
1 Replies

3. UNIX for Dummies Questions & Answers

Unix (compressed archieve, non-verbose)

I'm confusing with this question. :wall: Can any one tell me how to do and use which command? :confused: create a compressed archive of the "Test" directory and it's contents, called Test.tar.gz, and place it in the current directory. Use a non-verbose tar command with a single string, including... (5 Replies)
Discussion started by: wk9031
5 Replies

4. UNIX for Dummies Questions & Answers

archieve and zip the multiple file with no extension

Hi, I'm new to scripting. I need to find all the 10 files in the source directory and then archieve them to archive directory. The source files which im getting does not have any extensions just binary files. I need to find them by the file names and archive it. Directory also contains other... (1 Reply)
Discussion started by: etldeveloper
1 Replies

5. Emergency UNIX and Linux Support

How to delete all the files which are more than 3 weeks old in a particular directory.Thnx in advanc

(12 Replies)
Discussion started by: rajsharma
12 Replies

6. UNIX for Advanced & Expert Users

What is command to extract single file from an archieve?

I just want to extract one sigle file from an .ear archieve instead of extracting whole ear. Can anyone help me on this? (4 Replies)
Discussion started by: harshal_dcx
4 Replies

7. Shell Programming and Scripting

Delete the files older than 3 weeks in a particular directory.

Hi, Friends, I am writing a script to delete all the files which are there for more than 3 weeks. I have tried this : find /home/appl/backup -type f -mtime +21 -exec rm -f {} \; But i am not sure if it deletes only the files in specified directory or all the directorinies in the provieded... (3 Replies)
Discussion started by: rajsharma
3 Replies

8. Solaris

list files .txt and .TXT in one command

Dear experts, In a directory i have both *.TXT and *.txt files. I have a script- for file in `ls *.txt`; do mv $file /tmp/$file How to list both *.txt and*.TXT file in one command so that script will move both .txt or .TXT whatever it find. br//purple (4 Replies)
Discussion started by: thepurple
4 Replies

9. UNIX for Dummies Questions & Answers

echo "ABC" > file1.txt file2.txt file3.txt

Hi Guru's, I need to create 3 files with the contents "ABC" using single command. Iam using: echo "ABC" > file1.txt file2.txt file3.txt the above command is not working. pls help me... With Regards / Ganapati (4 Replies)
Discussion started by: ganapati
4 Replies

10. Shell Programming and Scripting

alternative for Archieve

Hi all , In order to zip the file ... first we need to use TAR and then GZIP on the TAR file ..... Is there any other method for zipping the files directly as in windows ( winzip ) Regards, Dhananjay (3 Replies)
Discussion started by: dhananjayk
3 Replies

Featured Tech Videos