mockers
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Shell Script to Compare 2 files

2 posters

Go down

Shell Script to Compare 2 files Empty Shell Script to Compare 2 files

Post  sriharsha Fri Feb 06, 2009 6:32 am

Write a Shell script to compare 2 files....
for example :-

$ cat file1

hhhhh 12
bbbbb 36

$ cat file 2

hhhhhh 63
bbbbb 11

It should proceed with comparing column by column... i mean first column of 1st file -> 1st column of 2nd file then 2nd column of 1st file -> 2nd column of 2nd file .............. like this

sriharsha

Posts : 21
Join date : 2009-02-02

Back to top Go down

Shell Script to Compare 2 files Empty Re: Shell Script to Compare 2 files

Post  sriharsha Fri Feb 20, 2009 2:13 pm

A sample solution can be of this form , as i exactly donno the solution Sad

$ cat compare2files.sh

Code:


echo " Enter the names of the files "
read file1 file2
cmp $file1 $file2
( or )
diff $file1 $file2


sriharsha

Posts : 21
Join date : 2009-02-02

Back to top Go down

Shell Script to Compare 2 files Empty Re: Shell Script to Compare 2 files

Post  Beagle Tue Feb 24, 2009 11:07 am

if you r using cmp or diff... then u don't require a shell script at all. I mean there's no point in making a shell script.

It would have been better if you had tried something with awk, sed, perl etc. I hope u r getting what i m trying to say.

Beagle

Posts : 40
Join date : 2009-01-30

Back to top Go down

Shell Script to Compare 2 files Empty Re: Shell Script to Compare 2 files

Post  sriharsha Sat Mar 07, 2009 11:35 am

Yeah ankit , what you r saying is perfect...
i donno why i wrote that ...
it's silly of me..
i will post the awk script for that very soon....

sriharsha

Posts : 21
Join date : 2009-02-02

Back to top Go down

Shell Script to Compare 2 files Empty Re: Shell Script to Compare 2 files

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum