How to compare size of two file which is in one directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to compare size of two file which is in one directory
# 1  
Old 01-08-2009
How to compare size of two file which is in one directory

I have two file in a Directory.I want a script which will compare the Size of Two file.
Can Anyone Help me on this:


linasplg11:/opt/dataout/kk/linasplg11 # cat size

-rwxrwxrwx 1 root root 16658 Jan 8 13:58 lina_IP_SIP_1231325621210.xml

-rwxr-xr-x 1 root root 16672 Jan 8 14:30 lina_IP_SIP_1231326111273.xml
# 2  
Old 01-08-2009
counter=0
cat size | while read a
do
if [ counter="1" ]
then
cmp2=`echo $a | awk -F " " '{print $5}'`
fi
else
cmp1=`echo $a | awk -F " " '{print $5}'`
elif
counter=`expr{counter+1}`
done

if (cmp1 > cmp2)
{your code|
else
{
your code
}
fi


bye bye
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare file size and then copy/overwrite

// Redhat I have this code working, but need to add one more qualification so that I don't overwrite the files. #!/bin/sh cd /P2/log/cerner_prod/millennium/archive/ for f in * do || continue #If this isn't a regular file, skip it. && continue #If a backup already... (2 Replies)
Discussion started by: Daniel Gate
2 Replies

2. UNIX for Dummies Questions & Answers

Ls directory size reporting byte size instead of file count

I have been searching both on Unix.com and Google and have not been able to find the answer to my question. I think it is partly because I can't come up with the right search terms. Recently, my virtual server switched storage devices and I think the problem may be related to that change.... (2 Replies)
Discussion started by: jmgibby
2 Replies

3. Shell Programming and Scripting

Script to Compare file size and delete the smaller

I am pretty new to scripting, so I appreciate your advice in advance. The problem: 100 directories each containing 2 files that have the same extension with random names. The only attribute that discriminates the files is size. I would like to write a script that compares the files for size... (6 Replies)
Discussion started by: JC_1
6 Replies

4. Shell Programming and Scripting

How to compare if the size of the directory is more than 500MB in unix

I use du -sk command to find the size of the directory but when i use the result of 'du -sk' into if statement its throwing error.. Could u solve with this..? (14 Replies)
Discussion started by: shaal89
14 Replies

5. Shell Programming and Scripting

How to delete some of the files in the directory, if the directory size limits the specified size

To find the whole size of a particular directory i use "du -sk /dirname".. but after finding the direcory's size how do i make conditions like if the size of the dir is more than 1 GB i hav to delete some of the files inside the dir (0 Replies)
Discussion started by: shaal89
0 Replies

6. UNIX for Dummies Questions & Answers

PSFTP- Compare file size

Hi, I'm using PSFTP to transfer files from one machine to a virtual machine with UBUNTU OS installed on it. I'm trying to find a way to make sure the files that I'm uploading / downloading are being uploaded/ downloaded properly. I want to compare the size of the local file and the remote... (0 Replies)
Discussion started by: sessie
0 Replies

7. Solaris

Directory size larger than file system size?

Hi, We currently have an Oracle database running and it is creating lots of processes in the /proc directory that are 1000M in size. The size of the /proc directory is now reading 26T. How can this be if the root file system is only 13GB? I have seen this before we an Oracle temp file... (6 Replies)
Discussion started by: sparcman
6 Replies

8. Shell Programming and Scripting

to write a script to compare the file size in the current directory and previous dir

hi, i am new to this site. i want to write a script to compare the file size of the files in the current dir with the files in the previous directory. the files name will be same, but the filename format will be as xyzddddyymm.txt. the files will arrive with the month end date(i want to... (5 Replies)
Discussion started by: tweety
5 Replies

9. Shell Programming and Scripting

compare file size from a output file from a script

Hi guys, firstly I'm working on SunOS 5.10 Generic_125100-10 sun4u sparc SUNW,Sun-Fire-V240 I've made a script to compress two directory and then send them to an other server via ftp. This is working very well. Inside theis script I decide to log usefull data for troubleshooting in case of... (7 Replies)
Discussion started by: moustik
7 Replies

10. Shell Programming and Scripting

How to compare file size after ftp?

Is possible if I want to campare file size on source and destination after ftp transfer? If anybody know, please explain to me. (1 Reply)
Discussion started by: icemania
1 Replies
Login or Register to Ask a Question