LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Gzip list of logfiles (https://www.linuxquestions.org/questions/linux-newbie-8/gzip-list-of-logfiles-944056/)

laks 05-09-2012 08:04 AM

Gzip list of logfiles
 
Hello,

I have a list of logfiles, whose names start with a common name and appended by .1, .2 etc(created by log4j). Now I want to retrieve these files from a shell script and run gzip for these files. Here is the code that I wrote, but it is not working.

PACKAGERLOGDIR is location of logfile
PACKAGER_LOGFILE is a file containing the String that these logfile names start with.

My Program is

find $PACKAGERLOGDIR -name ` cat $PACKAGER_LOGFILE` > $filelist

for file in `cat $filelist`; do

gzip $file

done.

This is not working. Could any help me find out where I am going wrong.

Thanks,
Lakshmi

pixellany 05-09-2012 08:17 AM

Take it one command at a time...

first, does your find statement produce the desired result? (Re-directing to a filename starting with "$" does not look right to me.)

chrism01 05-09-2012 07:47 PM

Wouldn't it be better just to use the logrotate tool to handle that automatically?


All times are GMT -5. The time now is 06:59 PM.