How to zip up a series of log files in one shot?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to zip up a series of log files in one shot?
# 1  
Old 07-21-2011
How to zip up a series of log files in one shot?

Hi, I'm trying to zip up the first half year's application logs into one zip file. The logs are in the format of log.2011-01-01 to log.2011-06-30.

I tried to use this command at ksh:
zip logs.jan-jun2011.zip *2011-01* *2011-02* *2011-03* *2011-04* *2011-05* *2011-06* It works.

However, I believe there's a better version of it. zip logs.jan-jun2011.zip *2011-[01-06]* does not work.

How can I group the files ranged from 01(Jan logs) to 06(Jun logs)?

Much Appreciated!

-Hui
# 2  
Old 07-21-2011
Code:
log.2011-0[1-6]-*

This User Gave Thanks to radoulov For This Post:
# 3  
Old 07-21-2011
Code:
*2011-[01-06]* 
# should be 
*2011-0[1-6]*

This User Gave Thanks to jim mcnamara For This Post:
# 4  
Old 07-21-2011
This is because [] isn't numeric, it accepts character ranges.
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 07-22-2011
Thanks to all helped me. Kudos!!! All of a sudden, I felt I'm connected to so many smart fellows here - no longer struggle by myself. This site is sooooo good!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. UNIX for Dummies Questions & Answers

Find all log files under all file systems older than 2 days and zip them

Hi All, Problem Statement:Find all log files under all file systems older than 2 days and zip them. Find all zip files older than 3days and remove them. Also this has to be set under cron. I have a concerns here find . -mtime +2 -iname "*.log" -exec gzip {} Not sure if this will work as... (4 Replies)
Discussion started by: saurabh.mishra
4 Replies

4. Shell Programming and Scripting

Zip Multiple files to One .zip file in AIX system

Hi I have a requirement in unix shell where I need to zip multiple files on server to one single .zip file. I dont see zip command in AIX and gzip command not doing completely what I want. One I do .zip file, I should be able to unzip in my local Computer. Here is example what I want... (9 Replies)
Discussion started by: RAMA PULI
9 Replies

5. Shell Programming and Scripting

Shell Script to zip users cmd history log files

I admit I am terrible with scripting, so when I was asked to store users' command history lines and zip them on monthly basis what I did was to create a file "user_history_Feb" with the following contents: Part A # more user_history_Feb cp -p /var/log/user_history/*history... (6 Replies)
Discussion started by: hedkandi
6 Replies

6. Shell Programming and Scripting

Identify log files based on time stamp,zip and then copy..HELP

Hi All, PFB is a requirement. I am new to shell scripting. So plz help. It would be highly appreciated. 1. choose all the log files based on a particular date (files location is '/test/domain')--i.e,we should choose all the files that are modified on 29th November, neither 28th nor 30th 2.... (3 Replies)
Discussion started by: skdas_niladri
3 Replies

7. AIX

ZIP multiple files and also specify size of zip file

I have to zip many pdf files and the size of zip file must not exceed 200 MB. When size is more than 200 MB then multiple zip files needs to be created. How we can achieve this in UNIX? I have tried ZIP utility but it takes a lot of time when we add individual pdfs by looping through a... (1 Reply)
Discussion started by: tom007
1 Replies

8. Shell Programming and Scripting

Deleting both hidden and regular files in a single shot

How to delete both hidden (. dot files) and regular files available in a directory in a single shot (just one pass instead of two rm commands)? The following are not helping: rm .* (or) rm \.* (or) rm .??* (or) rm * All these commands delete either hidden or regular files at one... (4 Replies)
Discussion started by: royalibrahim
4 Replies

9. Shell Programming and Scripting

remove a 350 files in one shot

i have a dir called logs. In it i have some 350 files how to move all those files from directory logs to a new dir called archive I want to do it in single shot Below the command i m trying but not getting find . -name "CurrentCollector*" -exec mv {} archive \;... (2 Replies)
Discussion started by: ali560045
2 Replies

10. UNIX for Dummies Questions & Answers

unzip .zip file and list the files included in the .zip archive

Hello, I am trying to return the name of the resulting file from a .zip archive file using unix unzip command. unzip c07212007.cef7081.zip Archive: c07212007.cef7081.zip SecureZIP for z/OS by PKWARE inflating: CEP/CEM7080/PPVBILL/PASS/G0063V00 I used the following command to unzip in... (5 Replies)
Discussion started by: oracledev
5 Replies
Login or Register to Ask a Question