lsbrown1
asked on
How to gzip multiple files in unix
I need to be able to gzip multiple .pdf and .txt files with a date stamp(filenamemmyydd) in the same folder in unix daily. Is a simple command or script to execute to perform this task?
Check the following link:
http://www.ehow.com/how_6955846_zip-multiple-files-unix.html
http://www.ehow.com/how_6955846_zip-multiple-files-unix.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>> gzip -c *.pdf *.txt > xx_xxxxx.`date +%Y-%m-%d`.gz
This command will create one .gz file that consists of the concatenated input files (pdf and txt) and then compressed.
Is this what you want? Or do you want to add the files to an archive first and them compress? In that case use this:
This command will create one .gz file that consists of the concatenated input files (pdf and txt) and then compressed.
Is this what you want? Or do you want to add the files to an archive first and them compress? In that case use this:
tar cfz xx_xxxxx.`date +%Y-%m-%d`.gz *.pdf *.txt
This way you will get one compressed archive containing each individual file (pdf and txt).
gzip only works on individual files. Use tar or zip instead, eg:
or
or if your tar version doesn't support the -z flag, do
zip file.`date +%Y-%m-%d.zip` *.pdf *.txt
or
tar czf file.`date +%Y-%m-%d.gz` *.pdf *.txt
or if your tar version doesn't support the -z flag, do
tar cf - *.pdf *.txt | gzip > file.`date +%Y-%m-%d.gz`
Did you try unzipping the .gz file that you get from the answer you chose? You cannot get individual .txt and .pdf files back from it. Sure you selected the right answer here?
lsbrown1, as gerwinjansen as already mentioned, the solution you have chosen will make it extremely difficult to extract your individual PDF files.
I would replace
gzip -c *.pdf *.txt > xx_xxxxx.`date +%Y-%m-%d`.gz
by
zip xx_xxxxx.`date +%Y-%m-%d` *.pdf *.txt
gzip -c *.pdf *.txt > xx_xxxxx.`date +%Y-%m-%d`.gz
by
zip xx_xxxxx.`date +%Y-%m-%d` *.pdf *.txt
ASKER
ftp -n xxx.xx.xx.xx <<END
username password
lcd /xxx/xxx/xxx
type binary
mget *.pdf
cd /xxx/xxx/xxx
gzip -c *.pdf *.txt > xx_xxxxx.`date +%Y-%m-%d`.gz
bye
END