compacting several files
Hi People ...
I would like to know which command and syntax I use to compact several text files in only one compressed file, and this file has to be readable for Windows machines (win Zip).
Nowadays I am using gzip, but I can only compact the files one by one using a loop. I do not want keep having a lot of files, I want only one file per day!
#!/bin/sh
fim=$(date +%s)
fim=$(( fim - 60 ))
#inicio=$(( fim - 86280 ))
inicio=$(( fim - 86220 ))
hoje=$(date +%d-%B-%Y)
path=/var/ftp/logsmrtg/$hoje
mkdir $path
#this creates the log files I want to compress
cd /var/www/html
for basedados in *.rrd; do
rrdtool fetch ${basedados} AVERAGE --start $inicio --end $fim > $path/${basedados}.log
done
#this changes the extension of the files and makes them
#windows-like
cd $path
rename .rrd.log .log *.rrd.log
unix2dos -q *.log
rm -f ../hoje/*.*
cp *.* ../hoje
chmod 755 ../hoje/*.*
#this compresses the files one by one
for basedados in *.log; do
gzip -afq --best -S .z $path/${basedados} > ${basedados}.z
done
chmod 755 *.z
:Pengy:
|