Comparing same size of files using KSH script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Comparing same size of files using KSH script
# 1  
Old 08-09-2010
Comparing same size of files using KSH script

Hi,

I have a requirement

I have to find out the same size of files with different name in a particular directory.

For ex: I have around 1 lack records in a directory and in that I have
abcd.jpg, abcd_1.jpg with same size each.

I need to seperate these two records from that file.

How can I find same size records with different name from a folder using korn shell script.

Please help me.

Thanks in advance,
# 2  
Old 08-09-2010
try this

Code:
#! /bin/bash

D="${1}"
TD=$(mktemp -d /tmp/XXXXXXXX)
T1=${TD}/t1.txt ; T2=${TD}/t2.txt

stat --printf ":%s: %n\n" ${D}/* > ${T1}
while read a b ; do
    echo "${a}"
done < ${T1} | sort | uniq > ${T2}

while read a ; do
    echo "[${a//:}]"
    sed -n "/${a}/ s/^:[0-9]*: /    /g p" ${T1}
done < ${T2}

rm -Rf ${TD}

# 3  
Old 08-09-2010
HI

I want the script in linux OS. Please help me.
# 4  
Old 08-09-2010
I forgot

I forgot to mention how to call the script:

store it in to a file, p.e. /tmp/sc.sh and make it executable:
Code:
    chmod a+rx /tmp/sc.sh

call it with your directory name:
Code:
    /tmp/sc.sh /usr/local

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script for comparing two files

Hi, I have 2 files as below FILE1.dat co1|co2|co3 abnd|45.56|AZ dkny|30.2|PA sam|.23|VA FILE.CTL FILENAME|FILE1.dat NO OF RECORDS|3 CHECKSUM|75.99 Could you please help me to write a shell script to compare 1. TOTAL RECORDS from FILE1.dat with NO of RECORDS in FILE.CTL 2.... (8 Replies)
Discussion started by: dreamsportsteam
8 Replies

2. Shell Programming and Scripting

Comparing 2 files using shell script

Hi Experts, I have 2 files 1 file consists of 800 records and 2 file consists of 100 records with matching column as Membership_Num.So i need a script which will compare the 2 files and displays the output.As these are the files the script should take any delimter like (tab,comma) as input... (6 Replies)
Discussion started by: naveen.dasu
6 Replies

3. Shell Programming and Scripting

Comparing the two files using awk script

Hi all, Can you please help me to find out that where is the problem in my script or either my way of writing the shell command on the prompt is not right? Actually, I want to compare the second column "$1" of the file "t1" with all the columns of second file "t2", if there is a match then the... (2 Replies)
Discussion started by: coder83
2 Replies

4. Shell Programming and Scripting

comparing 2 files in shell script

I have 2 files config1h.txt ----------------- BFMU=ENABLE,ID=PM THR=OFF,REP=ALL,CON=IACM,TIM=OFF;GPON collection strategy 1.3.6.1.2.1.2.2:8 1.3.6.1.2.1.2.2:7 1.3.6.1.4.1.637.61.1.35.11.4:4 1.3.6.1.4.1.637.61.1.35.11.4:3 1.3.6.1.4.1.637.61.1.35.10.1:2 1.3.6.1.4.1.637.61.1.35.10.1:43... (7 Replies)
Discussion started by: LavanyaP
7 Replies

5. Shell Programming and Scripting

Awk script / comparing two files

Goal: To combine the data from two files into one file. File1 = 11 fields, the first field is the unique key File2 = 2 fields, the first field is the unique key What I want to do is match File2:column1 with File1:column1 and if it matches, to add the data from File2:column2 to the matching... (2 Replies)
Discussion started by: jmcgranahan
2 Replies

6. Shell Programming and Scripting

ksh-script "arithmetic syntax error" comparing strings

Hi all, Iīve already searched the forum but canīt find what i am doing wrong. I am trying to compare two variables using ksh under red hat. The error I get is: -ksh: .: MDA=`md5sum /tmp/ftp_dir_after_transfer | cut -d' ' -f1 ` MDB=`md5sum /tmp/ftp_dir_before_transfer | cut -d' ' -f1 `... (3 Replies)
Discussion started by: old_mike
3 Replies

7. Shell Programming and Scripting

comparing two files using shell script

hi experts please help me to compare two files which are in different directory file1<file will be master file> (/home/rev/mas.txt} ex x1 x2 file2 <will be in different folder> (/home/rev/per/.....) ex x3 x4 the filesinside per folder i need to compare with master file and the files... (2 Replies)
Discussion started by: revenna
2 Replies

8. UNIX for Dummies Questions & Answers

shell script for comparing 2 files

Hi, how to read the 2 files and compare each other in shell script? i have 2 files test1 and test2, both files contains 20 character records.we have to compare file 1 records with file2, if exists then reject the record else we have to append it to test2 file. in file test1 around 100 single... (2 Replies)
Discussion started by: prashanth.spl
2 Replies

9. 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

10. UNIX for Advanced & Expert Users

Script error.. for comparing 2 files!

Hi I am using the below script to compare two files.. i am getting error as mentioned below: #!/bin/sh # Script to find the difference between 2 files # Remember the old file file1 should always be the first argument. Else, the logic would reverse. # diff.sh <old file> <new file> if ] ;... (4 Replies)
Discussion started by: gkrishnag
4 Replies
Login or Register to Ask a Question