Shell Script to Compare 2 files
2 posters
Shell Script to Compare 2 files
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
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
Re: Shell Script to Compare 2 files
A sample solution can be of this form , as i exactly donno the solution
$ cat compare2files.sh
$ 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
Re: Shell Script to Compare 2 files
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.
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
Re: Shell Script to Compare 2 files
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....
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
Permissions in this forum:
You cannot reply to topics in this forum