Zip size is different though files are same in ksh88


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Zip size is different though files are same in ksh88
# 1  
Old 07-03-2013
Zip size is different though files are same in ksh88

I'm using Ksh88 .
I've last day files in one directory and current month files in another directory , having the same naming convention.
Now i need to compare these folders size , if there is no change in these files then no action to be performed
else if there is a change then i need to call another script for ex: abc.sh
Now i tried this using zip -r command in the script, but though there is no difference in the file content in the 2 folders ,
the script is showing that the size is different .
Code:
#!/bin/ksh   
bas_file="/etc/home"
 zip -r zip_last.zip  "$bas_file/Lst_Day"
 zip -r zip_curr.zip  "$bas_file/Cur_Day"
  sze_last=$(ls -ltr zip_last.zip |awk '{ print $5 }')
  sze_curr=$(ls -ltr zip_curr.zip |awk '{ print $5 }')
  echo "$sze_last"    # here size is 1456
  echo "$sze_curr"    # here size is 1365 though 2 files are equal 
 if [[ $sze_last == $sze_curr ]]
  then
    echo "Equal"
 else
    echo "Not Equal"
 fi

What changes need to be done in the above script .

And suggest me the best way to compare files in folder .

Thank You

---------- Post updated at 01:33 PM ---------- Previous update was at 12:45 PM ----------

Could you please suggest me the best way to compare files in 2 directories.

I don't need the difference in 2 files after comparision just want to get the information that the files are equal or not .

I tried with CMP ,ZIP command , and waiting for your suggestions
Thanks

Last edited by smile689; 07-03-2013 at 04:23 AM..
# 2  
Old 07-03-2013
Even though the files may be the same, their path is not. zip will include the respective paths, and thus the difference in zip file sizes.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can we Zip multiple files created on the same date into one single zip file.?

Hi all i am very new to shell scripting and need some help from you to learn 1)i have some log files that gets generated on daily basis example: i have abc_2017_01_30_1.log ,2017_01_30_2.log like wise so i want to zip this 4 logs which are created on same date into one zip folder. 2)Post zipping... (1 Reply)
Discussion started by: b.saipriyanka
1 Replies

2. UNIX for Beginners Questions & Answers

How can we Zip multiple files created on the same date into one single zip file.?

Hi all i am very new to shell scripting and need some help from you to learn 1)i have some log files that gets generated on daily basis example: i have abc_2017_01_30_1.log ,2017_01_30_2.log like wise so i want to zip this 4 logs which are created on same date into one zip folder. 2)Post zipping... (2 Replies)
Discussion started by: b.saipriyanka
2 Replies

3. Shell Programming and Scripting

Append string to all the files inside a directory excluding subdirectories and .zip files

Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories. Eg. file1: test1.log file2: test2.log file3 test.zip After running the script file1: string_test1.log file2: string_test2.log file3:... (4 Replies)
Discussion started by: Ravi Kishore
4 Replies

4. Shell Programming and Scripting

Unzip all the files with subdirectories present and append a part of string from the main .zip files

Hi frnds, My requirement is I have a zip file with name say eg: test_ABC_UH_ccde2a_awdeaea_20150422.zip within that there are subdirectories on each directory we again have .zip files and in that we have files like mama20150422.gz and so on. Iam in need of a bash script so that it unzips... (0 Replies)
Discussion started by: Ravi Kishore
0 Replies

5. Shell Programming and Scripting

How to create zip/gz/tar files for if the files are older than particular days in UNIX or Linux?

I need a script file for backup (zip or tar or gz) of old log files in our unix server (causing the space problem). Could you please help me to create the zip or gz files for each log files in current directory and sub-directories also? I found one command which is to create gz file for the... (4 Replies)
Discussion started by: Mallikgm
4 Replies

6. Shell Programming and Scripting

Zip Multiple files to One .zip file in AIX system

Hi I have a requirement in unix shell where I need to zip multiple files on server to one single .zip file. I dont see zip command in AIX and gzip command not doing completely what I want. One I do .zip file, I should be able to unzip in my local Computer. Here is example what I want... (9 Replies)
Discussion started by: RAMA PULI
9 Replies

7. AIX

ZIP multiple files and also specify size of zip file

I have to zip many pdf files and the size of zip file must not exceed 200 MB. When size is more than 200 MB then multiple zip files needs to be created. How we can achieve this in UNIX? I have tried ZIP utility but it takes a lot of time when we add individual pdfs by looping through a... (1 Reply)
Discussion started by: tom007
1 Replies

8. UNIX for Dummies Questions & Answers

Size Limit for zip files

Hi, I am using the jar command to compress a directory. The size of the directory contents is 105 GB. The jar/zip that gets created is approximately 5.5 GB in size. But this file seems to be corrupt when verified using the unzip command. Is there any limitation for the size of the zip file?... (4 Replies)
Discussion started by: prafulasher
4 Replies

9. UNIX for Dummies Questions & Answers

unzip .zip file and list the files included in the .zip archive

Hello, I am trying to return the name of the resulting file from a .zip archive file using unix unzip command. unzip c07212007.cef7081.zip Archive: c07212007.cef7081.zip SecureZIP for z/OS by PKWARE inflating: CEP/CEM7080/PPVBILL/PASS/G0063V00 I used the following command to unzip in... (5 Replies)
Discussion started by: oracledev
5 Replies

10. Shell Programming and Scripting

bash script working for small size files but not for big size files.

Hi, I have one file stat. Stat file contents are as follows: for example. H50768020040913,00260100,507680,13,0000000643,0000000643,00000,0000 H50769520040808,00260100,507695,13,0000000000,0000000000,00000,0000 H50770620040611,00260100,507706,13,0000000000,0000000000,00000,0000 Now i... (1 Reply)
Discussion started by: davidpreml
1 Replies
Login or Register to Ask a Question