Specific file list to be zip


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Specific file list to be zip
# 8  
Old 02-28-2011
Yes,minimum is 5 and max 8 files. Smilie actually we need 20 days log files to be unzipped from the current date e.g. today the date is 28 feb we need a log files upto 08 feb. we can zip the rest of the previous files.

Moderator's Comments:
Mod Comment Please do not bump up threads.

Last edited by pludi; 02-28-2011 at 07:01 AM..
# 9  
Old 02-28-2011
Please, please, please give a list of criteria based on what files should be compressed, and which shouldn't, based on a general case, not on how the filesystem looks now. So far we have:
  • Files should be older than 10/20 days (which one is it now?)
  • At least 5, and up to 8 files should be compressed. How is this decided?
# 10  
Old 02-28-2011
OK here is the final req. If I run your script first time marking 4 red files alone should compress it. next time next 4 files marked in blue similarly goes on make sure current date log file -10 days back log file should not compress its marked in bold
Code:
-rw-r--r-- 1 root root        46 2011-01-25 20:24 ab_xxxxxx.log.log.201101252024.gz
-rw-r--r-- 1 root root        46 2011-01-26 19:10 ab_xxxxxx.log.log.201101261910.gz
-rw-r--r-- 1 root root         0 2011-01-27 19:56 ab_xxxxxx.log.log.201101271956
-rw-r--r-- 1 root root         0 2011-01-28 19:22 ab_xxxxxx.log.log.201101281922
-rw-r--r-- 1 root root         0 2011-01-29 21:41 ab_xxxxxx.log.log.201102281726
-rw-r--r-- 1 root root         0 2011-01-30 18:54 ab_xxxxxx.log.log.201101301854
-rw-r--r-- 1 root root         0 2011-01-31 18:58 ab_xxxxxx.log.log.201101311858
-rw-r--r-- 1 root root         0 2011-02-01 18:58 ab_xxxxxx.log.log.201102311858
-rw-r--r-- 1 root root         0 2011-02-02 18:58 ab_xxxxxx.log.log.201102021858
-rw-r--r-- 1 root root         0 2011-02-03 18:58 ab_xxxxxx.log.log.201102031858
.
.
.
.
.
.
-rw-r--r-- 1 root root         0 2011-02-04 18:58 ab_xxxxxx.log.log.201102041858
-rw-r--r-- 1 root root         0 2011-02-25 16:34 ab_xxxxxx.log.log.201102251634
-rw-r--r-- 1 root root         0 2011-02-26 17:18 ab_xxxxxx.log.log.201102261718
-rw-r--r-- 1 root root         0 2011-02-27 17:52 ab_xxxxxx.log.log.201102271752
-rw-r--r-- 1 root root         0 2011-02-28 11:28 ab_xxxxxx.log.log

If you need more clarification please give me ur IM ID. I can explain it better through call

Last edited by jagkoth; 02-28-2011 at 12:25 PM.. Reason: Code tags
# 11  
Old 02-28-2011
Quote:
Originally Posted by jagkoth
rdcwyx - First time it works. If I run the same command next time its not compressing the next 5 files. please see the error:

Code:
# ls -r ab_xxxxxx.20*|grep -v gz |sed -n '11,$p' |xargs gzip
gzip: compressed data not written to a terminal. Use -f to force compression.
For help, type: gzip -h

Because there is no files need be gzipped, after you run the command second times, you need test it the next day. Smilie

If you run gzip without any option or files, you will get this error:

Code:
$ gzip
gzip: compressed data not written to a terminal. Use -f to force compression.
For help, type: gzip -h

This User Gave Thanks to rdcwayx For This Post:
# 12  
Old 03-01-2011
MySQL

Thank you dude Smilie YOU ARE THE BEST Smilie
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. Shell Programming and Scripting

Uncompressing .zip file specific directory Fedora 14

Hello, I have Fedora 14 installed on my machine I have a .zip file ( some latex package) which I want to unzip to some location in the Latex paths /usr/share.../texmf/.. so I went to super user mode, created the directory for this package over there, mkdir logo and tried... (1 Reply)
Discussion started by: ajayram
1 Replies

4. Shell Programming and Scripting

Find all the files under a specific directory and zip them into a single file.

Hi, Is there a way to find all the files from a specific location and then zip them into a single file, even if they are in multiple directories? (3 Replies)
Discussion started by: rudoraj
3 Replies

5. Shell Programming and Scripting

Zip a list of specific files to an archive

Hi all, i've got the following problem: We've got a shell-script, that creates some different files based on several criteria given, using a sql-script. After creating, those files are individually zipped and stored, then sent to a ftp-server. This is all working since 2010, but now they have... (3 Replies)
Discussion started by: Biggreuda
3 Replies

6. UNIX for Dummies Questions & Answers

Zip file with specific name

Hi, How could compress a file with a specific name. For example if I put the following: gzip -f file.dat I compressed it with the same file name to compress, "file.dat.gz". How could compress it with the name I want for example test.gz. Thanks. (4 Replies)
Discussion started by: pepeli30
4 Replies

7. Shell Programming and Scripting

Matching a string (zip code) from a list in a separate file

I have a list of postal addresses and I need to pull the records that match a list of zip codes in a separate file. The postal addresses are fixed width. The zip code is located in character position 149-157. Something better than: cat postalfile.txt | grep -f zipcodes.txt would be great. $... (8 Replies)
Discussion started by: sitney
8 Replies

8. Shell Programming and Scripting

Read specific file from a zip archive without extracting

Hi All, I would like to extract specific file from a zip archive. I have a zip archive "sample.zip". sample.zip contains few text files and images... text1.txt, text2.txt, pic.jpg etc... I need to read specific file "text2.txt" from "sample.zip" WITHOUT EXTRACTING the zip file. ... (4 Replies)
Discussion started by: sridharg
4 Replies

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

10. UNIX for Dummies Questions & Answers

Is extracting specific files from a zip file possible?

If a zip file contains several zip files, but if the file names of the files needed are known, is there a variation of the unzip command that will allow those few (individual) files to be extracted? --- Example: Zip file name: zip.zip unzip -l zip.zip will display file01, file02, file03, etc.... (1 Reply)
Discussion started by: HLee1981
1 Replies
Login or Register to Ask a Question