Zip all the files within a directory on a daily basis


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Zip all the files within a directory on a daily basis
# 1  
Old 05-14-2007
Zip all the files within a directory on a daily basis

I need to zip all the files within a directory on a daily basis and store them as a zip file within that directory with the date in its naming convention

I have file extentions .log .lst and .out's within that directory

How do i do this task

zip -mqj mydir/allzip$YYMMDDDD.zip mydir/*.*

my question is I cannot give a *.* in the end. because tomorrow i will have todays zip file and i dont want to include this into my today's zip file how do i accomplish this.

Any thoughts are appreciated

Regards
Ram
# 2  
Old 05-14-2007
Ram,
See if this would work for you:
Code:
zip -mqj mydir/allzip$YYMMDDDD.zip `ls -1 mydir/*.log mydir*.out mydir/*.lst`

# 3  
Old 05-14-2007
Try :
Code:
zip -mqj mydir/allzip$YYMMDDDD.zip mydir/*.log mydir/*.lst mydir/*.out

Jean-Pierre.
# 4  
Old 05-14-2007
Code:
!#/bin/ksh
zip -mqj mydir/allzip$YYYYMMDD.zip mydir/*.@(.lst|.out|.log)

will select files with the three endings: .out .lst .log
Try it with ls on your system first.
# 5  
Old 05-14-2007
Jim,
Great solution!
Since it already has a "." before the "@", it is not needed before the extensions, in other words, it would be like:
Code:
zip -mqj mydir/allzip$YYYYMMDD.zip mydir/*.@(lst|out|log)

# 6  
Old 05-14-2007
Zipping log files

Yes It Works a big thanks to everyone.

By the way how do i zip for files with yestedays time stamp only. I do not want to zip todays files .As i do not have a timestamp in the naming coventions of this log,lst and out files.....
How do i only zip files with yesterdays time stamp on them.

Regards
Ram
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to count files on daily basis

Hi all I need to count files on a daily basis and send the output via email, what I am currently doing its simply running the following:ls -lrt *.cdr | awk '{if(($6 == "Jul") && ($7 == "13")) print $0}' | wc -l, which in this case it will count all files with extension "cdr" from the month of... (13 Replies)
Discussion started by: fretagi
13 Replies

2. Shell Programming and Scripting

Append string to all the files inside a directory excluding subdirectories and .zip files

Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories. Eg. file1: test1.log file2: test2.log file3 test.zip After running the script file1: string_test1.log file2: string_test2.log file3:... (4 Replies)
Discussion started by: Ravi Kishore
4 Replies

3. Shell Programming and Scripting

Check daily files arrival in a directory

Hi All, I wanted to write a script to check if set of files exist in a directory or not for a particular day. each file has a date stamp. Now i want to implement this - -i can check files of a particular date in a particular folder -generate log and send it to through email. Big THANKS !!... (5 Replies)
Discussion started by: flagboy2014
5 Replies

4. Shell Programming and Scripting

Script to move file on a daily basis

Hi! Please I need help on the a script that would pick one file in a directory, change its name, them change its permissions, them move to a different directory, but has to be done on a daily basis, and the file that is being moved to its final destination has to have the following format:... (7 Replies)
Discussion started by: fretagi
7 Replies

5. UNIX for Dummies Questions & Answers

Tracking the script(.sh) files triggered on daily or monthly basis from source

Hi Gurus, Is there any solution for tracking the script(.sh) files triggered on daily or monthly basis from source - Datastage (Routines) Needs to find out if this scripts are running on daily just want to know that is there anything to track Thanks in Advance (2 Replies)
Discussion started by: SeenuGuddu
2 Replies

6. UNIX for Dummies Questions & Answers

Zip all files in a directory and move to another directory

Hi, need to zip all files in a directory and move to another directory after the zip.. i am using this one but didnt help me... zip -r my_proj_`date +%Y%m%d%H%MS`.zip /path/my_proj mv in_proj_`date +%Y%m%d%H%M%S`.zip /path/source/ i am trying to zip all the files in my_proj... (0 Replies)
Discussion started by: dssyadav
0 Replies

7. Shell Programming and Scripting

Creating directory daily basis...

Need help on this script. the month is not changing to February... #!/bin/bash for X in `seq 1 100` do DATE=`date +%Y-%m-%d "--date=${X} day ago"` Y=`date +%Y` M=`date +%m` D=`date +%d "--date=${X} day ago"` DIR=/home/LogBackup for i in `seq 1 ` do if ;then # ... (1 Reply)
Discussion started by: alelee
1 Replies

8. UNIX for Dummies Questions & Answers

Zip files inside the directory, but not the directory itself

Hi, Im facing a problem that im stucked, I have the following structure: thales@pereirtc-vbox:/home/VfARM$ ls code config doc lib manifest.bak manifest.rel manifest.v3 ns pub if i try to execute zip -q -o arm.zip VfARM/* it will create a zip file with the folder VfARM.... (2 Replies)
Discussion started by: Thales.Claro
2 Replies

9. HP-UX

HPUX printers & plotters disable on a daily basis

HI all, I've been having issues with printers and plotters disabling with no reason at all...It could happen to the same workstation once a day or once a week..There is nothing consistant..I stop and restart the spooler, only then can I re-enable the disabled printer.... If anyone is... (0 Replies)
Discussion started by: Shutdown
0 Replies
Login or Register to Ask a Question