Hi Team,
Version : Ksh 88
The Requirement is to zip every file in a folder(which is in for loop) and move the zipped file to another folder
I tried like the below , but didn't observe any change ( Infact more size ) after the file is zipped .
#!/bin/ksh
src_dir=/home/etc/Src_dat
dest_dir=/home/etc/zipped_dat
for test_file in `ls $src_dir`
do
cd $src_dir
zip "$test_file.zip" "$test_file"
mv $src_dir/$test_file.zip $dest_dir
done
With the code like above , I observe that
In the source folder the size of the file was 158 Data_day1.txt
In the destination folder the size of the file is 273 Data_day1.txt
Please advice where is the wrong in the above code !!!
Thank You
Thank You for the reply Rakesh,
I'm sorry , I didn't understand about headers
Thanks
Thank You for the information Rakesh,
Can you please suggest me any change in the script so that it zip the every file correctly .
Or Is this fine ..
Thanks,
if you want to see the size difference with Zip, please try with a bigger file like say 1MB.
Before Zip
rakesh@xyz:/tmp/zlinux> du cics_log_01-09-12-22\:56\:00.tar.gz
4 cics_log_01-09-12-22:56:00.tar.gz
After zip , its size is increased due to zip headers
rakesh@xyz:/tmp/zlinux> ls -l cics_log_01-09-12-22\:56\:00.tar.gz*
-rw-r--r-- 1 rakesh users 45 2013-09-10 06:13 cics_log_01-09-12-22:56:00.tar.gz
-rw-r--r-- 1 rakesh users 239 2013-09-10 06:14 cics_log_01-09-12-22:56:00.tar.gz.zip
---------- Post updated at 06:21 AM ---------- Previous update was at 06:20 AM ----------
your method is correct and you can go ahead, but you can test it with unzip just to make sure its doesn't loose integrity