Need to zip the files date wise --urgent Help needed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to zip the files date wise --urgent Help needed
# 1  
Old 05-28-2009
Need to zip the files date wise --urgent Help needed

Hi all,

this is my first post, i need to write a script to zip the files with datewise below are the log files.

-rw------- 1 root sso 85316156 May 24 22:11 core_test_smservaz_104_104_1243217459_8896
-rw------- 1 root sso 90413304 May 25 22:12 core_test_smservaz_104_104_1243303895_20912
-rw------- 1 root sso 86430300 May 26 22:11 core_test_smservaz_104_104_1243390261_3526

Need to zip the previous date only, Current date file should not be zipped.

Please help me writing script..
# 2  
Old 05-28-2009
i will give you a head start , since you are first post.
you can use find with -mtime +1 to find files more than 1 day old. pass it through a while read loop and zip the file. man zip for more info on zip. (or you can use -exec directly)
# 3  
Old 05-28-2009
for the files older than 1 day in the current dir

find . -mtime +1 -print | zip zipfilename -@
# 4  
Old 05-28-2009
thanks for your replies,

when i tried the above comands, while running the script
i m getting the below error message,

/var/tmp/chandu/backup/core_test_smserv.gz
gzip: /var/tmp/chandu/backup/core_test_smserv.gz already has .gz suffix -- unchanged
/var/tmp/chandu/backup/core_test_smservauth.gz
gzip: /var/tmp/chandu/backup/core_test_smservauth.gz already has .gz suffix -- unchanged
/var/tmp/chandu/backup/core_test_smservauth_1234.gz

hlep me in this....

regards,
Chandrasekhar
# 5  
Old 05-28-2009
Code:
find . -type f -mtime +1 -exec gzip {} \;


-Devaraj Takhellambam
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Csv files sort by date and zip monthly

Hi, I'm an absolute beginner in shell programming. I would need a script for a NAS that makes the csv files sorted by date and always monthly a zip. In the current month, the data should be integrated into this folder, so there are only monthly files. Thanks for your help (1 Reply)
Discussion started by: Pipo
1 Replies

2. Shell Programming and Scripting

How can we Zip multiple files created on the same date into one single zip file.?

Hi all i am very new to shell scripting and need some help from you to learn 1)i have some log files that gets generated on daily basis example: i have abc_2017_01_30_1.log ,2017_01_30_2.log like wise so i want to zip this 4 logs which are created on same date into one zip folder. 2)Post zipping... (1 Reply)
Discussion started by: b.saipriyanka
1 Replies

3. UNIX for Beginners Questions & Answers

How can we Zip multiple files created on the same date into one single zip file.?

Hi all i am very new to shell scripting and need some help from you to learn 1)i have some log files that gets generated on daily basis example: i have abc_2017_01_30_1.log ,2017_01_30_2.log like wise so i want to zip this 4 logs which are created on same date into one zip folder. 2)Post zipping... (2 Replies)
Discussion started by: b.saipriyanka
2 Replies

4. Shell Programming and Scripting

Extract count of string in all files and display on date wise

Hi All, hope you all are doing well! I kindly ask you for shell scripting help, here is the description: I have huge number of files shown below on date wise, which contains different strings(numbers you can say) including 505001 and 602001. ... (14 Replies)
Discussion started by: VasuKukkapalli
14 Replies

5. Shell Programming and Scripting

How to read files by Server Creation date wise?

Hi All, I would have many files in the server with xyz*.dat -- Static file name Physical files: xyz1.dat - 01PM xyz2.dat - 02PM xyz3.dat - 03PM In present version we are using for f in $file_name do fname=`ls $f | grep -v ^'\|'$ | sed s/' '/'\\ '/g` .... sqlldr... (4 Replies)
Discussion started by: Dharv
4 Replies

6. Shell Programming and Scripting

List files with Date Range and Zip it

Hi all, I am using the below script which display the files in the folder with the date range we specify. I want to add extra functionality that, The listing files should be zipped using gzip. I tried to add exec gzip at the last line but it is not working. Suggestions please. ... (2 Replies)
Discussion started by: nokiak810
2 Replies

7. Solaris

delete files by date wise

Hi guys, I want to delete files from june 13 to june 30, using rm command can any one tell me the sintax to remove. I ahve hunderd of core files in my /var dir. so i want to clear last month core files. Thanks in Advance.:)) (2 Replies)
Discussion started by: kurva
2 Replies

8. Shell Programming and Scripting

URGENT: Script/Function needed to read text property files in block wise

Hi, Iam in a need for a script/function in KSH where I want to read a text file (property file) in block by block. Here is the example: Heading Name Descripton Block Block1 Value1 Description Property Name Value Property Name Value Property Name Value Property Name Value Property Name... (7 Replies)
Discussion started by: ysreenivas
7 Replies

9. Shell Programming and Scripting

Zip files by date

Hello, I need to create a bash script file that zip files. The obj is : the script enter into a directory, see all directories, and zip the files by date ( the script is for managment of logfiles ), exemple: in the directory there is just files following the name "ex090210" (yymmdd ), so i need... (1 Reply)
Discussion started by: joinup
1 Replies

10. UNIX for Advanced & Expert Users

urgent help needed!!in copying files to /tmp at boot time,pls help!

Hi all, I am trying to boot a an OS from RAM...(its a opensolaris based distro) For this i have picked up 2 key lib files that when copied to /tmp and mounted to respective places will do the job.. The sizes of these files combined comes upto 600mb.(i have 2gb ram) Now i have also located the... (0 Replies)
Discussion started by: wrapster
0 Replies
Login or Register to Ask a Question