LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-13-2003, 03:53 PM   #1
davi_cabral
LQ Newbie
 
Registered: Jul 2003
Location: Rio
Distribution: RedHat 7.2
Posts: 21

Rep: Reputation: 15
Question 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:
 
Old 08-13-2003, 09:56 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
As far as I know, any recent version of WinZip can handle tar archives. So just tar the files you want, and gzip them.

You could also try zip. It allows multiple files to be placed in a single archive. It's compatible with PKZIP which I believe is WinZip's underlying compression routine (but I can't say that with any certainty).

You could also use the setup given in the "ADVANCED USAGE" section of the man page for gzip. It isn't a clean solution because the archive's individual pieces don't unpack into spearate files. There are ways around this problem, but it's probably not worth the effort.
 
Old 08-13-2003, 10:32 PM   #3
contrasutra
LQ Guru
 
Registered: Mar 2003
Location: New Jersey
Distribution: Arch Linux
Posts: 1,445

Rep: Reputation: 47
Why not tar up the files before gziping them?

tar -cvvf /path/to/new/tar.tar /path/to/directory/to/tar

then - gzip -rv /path/to/tar.tar

That will create a tar.gz of the directory you specified.
 
Old 08-14-2003, 08:26 AM   #4
davi_cabral
LQ Newbie
 
Registered: Jul 2003
Location: Rio
Distribution: RedHat 7.2
Posts: 21

Original Poster
Rep: Reputation: 15
thanks

Contrasutra, thanks!
It works for me. Now, lets implement it!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Able to write files to MP3 player but no files written into actual device? olnex Linux - Hardware 0 11-11-2005 06:32 AM
Compacting copied DVD files daihard Linux - Software 2 07-10-2005 08:52 PM
How program to read files with extension .dat y .cfg files COMTRADE in fedora 1? ivonne Linux - Software 0 11-22-2004 11:42 AM
How can konqueror view html files in .gz & .bz2 files directly? ailinzhe Linux - Software 5 05-24-2004 08:36 AM
How to filter files in files and files which are in a sub-directory with "grep"? Piero Linux - Newbie 9 08-29-2003 02:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration