comparing 2 files in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting comparing 2 files in shell script
# 1  
Old 05-17-2011
comparing 2 files in shell script

I have 2 files
config1h.txt
-----------------
Code:
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
1.3.6.1.4.1.637.61.1.35.10.1:4
1.3.6.1.4.1.637.61.1.35.10.1:5
1.3.6.1.4.1.637.61.1.35.10.1:20
1.3.6.1.4.1.637.61.1.35.10.1:26
1.3.6.1.4.1.637.61.1.35.11.2:4
1.3.6.1.4.1.637.61.1.35.11.2:14
1.3.6.1.4.1.637.61.1.35.11.2:19
1.3.6.1.4.1.637.61.1.35.11.2:15
1.3.6.1.4.1.637.61.1.35.11.2:13
1.3.6.1.4.1.637.61.1.35.11.2:12
1.3.6.1.4.1.637.61.1.35.10.14:3
1.3.6.1.4.1.637.61.1.35.10.14:5
1.3.6.1.4.1.637.61.1.35.10.14:2
1.3.6.1.4.1.637.61.1.35.10.14:4
1.3.6.1.4.1.637.61.1.35.10.14:6
1.3.6.1.4.1.637.61.1.35.10.18:2
1.3.6.1.4.1.637.61.1.35.10.19:1
1.3.6.1.4.1.637.61.1.35.10.19:12
1.3.6.1.4.1.637.61.1.35.10.19:11
1.3.6.1.4.1.637.61.1.35.10.19:13
1.3.6.1.4.1.637.61.1.35.10.19:10
1.3.6.1.4.1.637.61.1.35.10.4:3
1.3.6.1.4.1.637.61.1.35.10.4:2
1.3.6.1.4.1.637.61.1.35.15.3:3
1.3.6.1.4.1.637.61.1.35.15.3:4
1.3.6.1.4.1.637.61.1.23.3:8
1.3.6.1.4.1.637.61.1.23.3:3
1.3.6.1.4.1.637.61.1.23.3:6
1.3.6.1.4.1.637.61.1.23.3:5
0

PM09134500
--------------------
Code:
BFMU Version: V1 
START TIME: 17/05/11 08:00:30.000000
1.3.6.1.2.1.2.2
.1:8.285306880=1
.1:8.285306881=1
.1:8.285306882=1
.1:8.285306883=1
.1:8.285306884=1
.1:8.285306885=1
.1:8.285736960=1
.1:8.285736961=1
.1:8.286064640=2
.1:8.286064641=2
.1:8.286064642=2
.1:8.286064643=2
1.3.6.1.2.1.2.2
.1:7.285306880=1
.1:7.285306881=1
.1:7.285306882=1
.1:7.285306883=1
.1:7.285306884=1
.1:7.285306885=1
.1:7.285736960=1
.1:7.285736961=1
.1:7.286064640=2
.1:7.286064641=2
.1:7.286064642=2
.1:7.286064643=2
1.3.6.1.4.1.637.61.1.35.11.4
.1:4.285736960.1=0
.1:4.285736960.2=0
.1:4.285736960.3=0
.1:4.285736960.4=0
.1:4.285736960.5=0
.1:4.285736960.6=0
.1:4.285736960.7=0
.1:4.285736960.8=0
.1:4.285736960.9=0
.1:4.285736960.10=0
.1:4.285736960.11=0
.1:4.285736960.12=0
.1:4.285736960.13=0
.1:4.285736960.14=0
.1:4.285736960.15=0
.1:4.285736960.16=0
.1:4.285736960.17=0
.1:4.285736960.18=0
.1:4.285736960.19=0
.1:4.285736960.20=0
.1:4.285736960.21=0
.1:4.285736960.22=0
.1:4.285736960.23=0
.1:4.285736960.24=0
.1:4.285736960.25=0
.1:4.285736960.26=0
.1:4.285736960.27=0
.1:4.285736960.28=0
.1:4.285736960.29=0
.1:4.285736960.30=0
.1:4.285736960.31=0
.1:4.285736960.32=0
.1:4.285736960.33=0
.1:4.285736960.34=0
.1:4.285736960.35=0
.1:4.285736960.36=0
.1:4.285736960.37=0
.1:4.285736960.38=0
.1:4.285736960.39=0
.1:4.285736960.40=0
.1:4.285736960.41=0
.1:4.285736960.42=0
.1:4.285736960.43=0
.1:4.285736960.44=0
.1:4.285736960.45=0
.1:4.285736960.46=0
.1:4.285736960.47=0
.1:4.285736960.48=0
.1:4.285736960.49=0
.1:4.285736960.50=0
.1:4.285736960.51=0
.1:4.285736960.52=0
.1:4.285736960.53=0
.1:4.285736960.54=0
.1:4.285736960.55=0
.1:4.285736960.56=0
.1:4.285736960.57=0
.1:4.285736960.58=0
.1:4.285736960.59=0
.1:4.285736960.60=0
.1:4.285736960.61=0
.1:4.285736960.62=0
.1:4.285736960.63=0
.1:4.285736960.64=0
.1:4.285736961.1=0
.1:4.285736961.2=0
.1:4.285736961.3=0
.1:4.285736961.4=0
.1:4.285736961.5=0
.1:4.285736961.6=0
.1:4.285736961.7=0
.1:4.285736961.8=0
.1:4.285736961.9=0
.1:4.285736961.10=0
.1:4.285736961.11=0
.1:4.285736961.12=0
.1:4.285736961.13=0
.1:4.285736961.14=0
.1:4.285736961.15=0
.1:4.285736961.16=0
.1:4.285736961.17=0
.1:4.285736961.18=0
.1:4.285736961.19=0
.1:4.285736961.20=0
.1:4.285736961.21=0
.1:4.285736961.22=0
.1:4.285736961.23=0
.1:4.285736961.24=0
.1:4.285736961.25=0
.1:4.285736961.26=0
.1:4.285736961.27=0
.1:4.285736961.28=0
.1:4.285736961.29=0
.1:4.285736961.30=0
.1:4.285736961.31=0
.1:4.285736961.32=0
.1:4.285736961.33=0
.1:4.285736961.34=0
.1:4.285736961.35=0
.1:4.285736961.36=0
.1:4.285736961.37=0
.1:4.285736961.38=0
.1:4.285736961.39=0
.1:4.285736961.40=0
.1:4.285736961.41=0
.1:4.285736961.42=0
.1:4.285736961.43=0
.1:4.285736961.44=0
.1:4.285736961.45=0
.1:4.285736961.46=0
.1:4.285736961.47=0
.1:4.285736961.48=0
.1:4.285736961.49=0
.1:4.285736961.50=0
.1:4.285736961.51=0
.1:4.285736961.52=0
.1:4.285736961.53=0
.1:4.285736961.54=0
.1:4.285736961.55=0
.1:4.285736961.56=0
.1:4.285736961.57=0
.1:4.285736961.58=0
.1:4.285736961.59=0
.1:4.285736961.60=0
.1:4.285736961.61=0
.1:4.285736961.62=0
.1:4.285736961.63=0
.1:4.285736961.64=0
.1:4.286064640.1=0
.1:4.286064640.2=0
.1:4.286064640.3=0
.1:4.286064640.4=0
.1:4.286064640.5=0
.1:4.286064640.6=0
.1:4.286064640.7=0
.1:4.286064640.8=0
.1:4.286064640.9=0
.1:4.286064640.10=0
.1:4.286064640.11=0
.1:4.286064640.12=0
.1:4.286064640.13=0
.1:4.286064640.14=0
.1:4.286064640.15=0
.1:4.286064640.16=0
.1:4.286064640.17=0
.1:4.286064640.18=0
.1:4.286064640.19=0
.1:4.286064640.20=0
.1:4.286064640.21=0
.1:4.286064640.22=0
.1:4.286064640.23=0
.1:4.286064640.24=0
.1:4.286064640.25=0
.1:4.286064640.26=0
.1:4.286064640.27=0
.1:4.286064640.28=0
.1:4.286064640.29=0
.1:4.286064640.30=0
.1:4.286064640.31=0
.1:4.286064640.32=0
.1:4.286064640.33=0
.1:4.286064640.34=0
.1:4.286064640.35=0
.1:4.286064640.36=0
.1:4.286064640.37=0
.1:4.286064640.38=0
.1:4.286064640.39=0
.1:4.286064640.40=0
.1:4.286064640.41=0
.1:4.286064640.42=0
.1:4.286064640.43=0
.1:4.286064640.44=0
.1:4.286064640.45=0
.1:4.286064640.46=0
.1:4.286064640.47=0
.1:4.286064640.48=0
.1:4.286064640.49=0
.1:4.286064640.50=0
.1:4.286064640.51=0
.1:4.286064640.52=0
.1:4.286064640.53=0
.1:4.286064640.54=0
.1:4.286064640.55=0
.1:4.286064640.56=0
.1:4.286064640.57=0
.1:4.286064640.58=0
.1:4.286064640.59=0
.1:4.286064640.60=0
.1:4.286064640.61=0
.1:4.286064640.62=0
.1:4.286064640.63=0
.1:4.286064640.64=0
.1:4.286064641.1=0
.1:4.286064641.2=0
.1:4.286064641.3=0
.1:4.286064641.4=0
.1:4.286064641.5=0
.1:4.286064641.6=0
.1:4.286064641.7=0
.1:4.286064641.8=0
.1:4.286064641.9=0
.1:4.286064641.10=0
.1:4.286064641.11=0
.1:4.286064641.12=0
.1:4.286064641.13=0
.1:4.286064641.14=0
.1:4.286064641.15=0
.1:4.286064641.16=0
.1:4.286064641.17=0
.1:4.286064641.18=0
.1:4.286064641.19=0
.1:4.286064641.20=0
.1:4.286064641.21=0
.1:4.286064641.22=0
.1:4.286064641.23=0
.1:4.286064641.24=0
.1:4.286064641.25=0
.1:4.286064641.26=0
.1:4.286064641.27=0
.1:4.286064641.28=0
.1:4.286064641.29=0
.1:4.286064641.30=0
.1:4.286064641.31=0
.1:4.286064641.32=0
.1:4.286064641.33=0
.1:4.286064641.34=0
.1:4.286064641.35=0
.1:4.286064641.36=0
.1:4.286064641.37=0
.1:4.286064641.38=0
.1:4.286064641.39=0
.1:4.286064641.40=0
.1:4.286064641.41=0
.1:4.286064641.42=0
.1:4.286064641.43=0
.1:4.286064641.44=0
.1:4.286064641.45=0
.1:4.286064641.46=0
.1:4.286064641.47=0
.1:4.286064641.48=0
.1:4.286064641.49=0
.1:4.286064641.50=0
.1:4.286064641.51=0
.1:4.286064641.52=0
.1:4.286064641.53=0
.1:4.286064641.54=0
.1:4.286064641.55=0
.1:4.286064641.56=0
.1:4.286064641.57=0
.1:4.286064641.58=0
.1:4.286064641.59=0
.1:4.286064641.60=0
.1:4.286064641.61=0
.1:4.286064641.62=0
.1:4.286064641.63=0
.1:4.286064641.64=0
.1:4.286064642.1=0
.1:4.286064642.2=0
.1:4.286064642.3=0
.1:4.286064642.4=0
.1:4.286064642.5=0
.1:4.286064642.6=0
.1:4.286064642.7=0
.1:4.286064642.8=0
.1:4.286064642.9=0
.1:4.286064642.10=0
.1:4.286064642.11=0
.1:4.286064642.12=0
.1:4.286064642.13=0
.1:4.286064642.14=0
.1:4.286064642.15=0
.1:4.286064642.16=0
.1:4.286064642.17=0
.1:4.286064642.18=0
.1:4.286064642.19=0
.1:4.286064642.20=0
.1:4.286064642.21=0
.1:4.286064642.22=0
.1:4.286064642.23=0
.1:4.286064642.24=0
.1:4.286064642.25=0
.1:4.286064642.26=0
.1:4.286064642.27=0
.1:4.286064642.28=0
.1:4.286064642.29=0
.1:4.286064642.30=0
.1:4.286064642.31=0
.1:4.286064642.32=0
.1:4.286064642.33=0
.1:4.286064642.34=0
.1:4.286064642.35=0
.1:4.286064642.36=0
.1:4.286064642.37=0
.1:4.286064642.38=0
.1:4.286064642.39=0
.1:4.286064642.40=0
.1:4.286064642.41=0
.1:4.286064642.42=0
.1:4.286064642.43=0
.1:4.286064642.44=0
.1:4.286064642.45=0
.1:4.286064642.46=0
.1:4.286064642.47=0
.1:4.286064642.48=0
.1:4.286064642.49=0
.1:4.286064642.50=0
.1:4.286064642.51=0
.1:4.286064642.52=0
.1:4.286064642.53=0
.1:4.286064642.54=0
.1:4.286064642.55=0
.1:4.286064642.56=0
.1:4.286064642.57=0
.1:4.286064642.58=0
.1:4.286064642.59=0
.1:4.286064642.60=0
.1:4.286064642.61=0
.1:4.286064642.62=0
.1:4.286064642.63=0
.1:4.286064642.64=0
.1:4.286064643.1=0
.1:4.286064643.2=0
.1:4.286064643.3=0
.1:4.286064643.4=0
.1:4.286064643.5=0
.1:4.286064643.6=0
.1:4.286064643.7=0
.1:4.286064643.8=0
.1:4.286064643.9=0
.1:4.286064643.10=0
.1:4.286064643.11=0
.1:4.286064643.12=0
.1:4.286064643.13=0
.1:4.286064643.14=0
.1:4.286064643.15=0
.1:4.286064643.16=0
.1:4.286064643.17=0
.1:4.286064643.18=0
.1:4.286064643.19=0
.1:4.286064643.20=0
.1:4.286064643.21=0
.1:4.286064643.22=0
.1:4.286064643.23=0
.1:4.286064643.24=0
.1:4.286064643.25=0
.1:4.286064643.26=0
.1:4.286064643.27=0
.1:4.286064643.28=0
.1:4.286064643.29=0
.1:4.286064643.30=0
.1:4.286064643.31=0
.1:4.286064643.32=0
.1:4.286064643.33=0
.1:4.286064643.34=0
.1:4.286064643.35=0
.1:4.286064643.36=0
.1:4.286064643.37=0
.1:4.286064643.38=0
.1:4.286064643.39=0
.1:4.286064643.40=0
.1:4.286064643.41=0
.1:4.286064643.42=0
.1:4.286064643.43=0
.1:4.286064643.44=0
.1:4.286064643.45=0
.1:4.286064643.46=0
.1:4.286064643.47=0
.1:4.286064643.48=0
.1:4.286064643.49=0
.1:4.286064643.50=0
.1:4.286064643.51=0
.1:4.286064643.52=0
.1:4.286064643.53=0
.1:4.286064643.54=0
.1:4.286064643.55=0
.1:4.286064643.56=0
.1:4.286064643.57=0
.1:4.286064643.58=0
.1:4.286064643.59=0
.1:4.286064643.60=0
.1:4.286064643.61=0
.1:4.286064643.62=0
.1:4.286064643.63=0
.1:4.286064643.64=0
1.3.6.1.4.1.637.61.1.35.11.4
.1:3.285736960.1=9
.1:3.285736960.2=26
.1:3.285736960.3=7
.1:3.285736960.4=10
.1:3.285736960.5=0
.1:3.285736960.6=0
.1:3.285736960.7=0
.1:3.285736960.8=0
.1:3.285736960.9=0
.1:3.285736960.10=0
.1:3.285736960.11=0
.1:3.285736960.12=0

Now i need to compare 2 files and give the output
the strategy here is that all the config entries should be compared with pmfile
The one in config file
Code:
1.3.6.1.2.1.2.2:8

pmfile
Code:
1.3.6.1.2.1.2.2
.1:8.285306880=1

this means that "1.3.6.1.2.1.2.2" is covered in pmfile and ":8"in config file is represented as ".1:8" in pmfile .Like wise the others

Now my shell script output should be
Code:
1.3.6.1.2.1.2.2:8    TRUE
1.3.6.1.2.1.2.2:7    TRUE
1.3.6.1.4.1.637.61.1.35.11.4:4    TRUE
1.3.6.1.4.1.637.61.1.35.11.4:3    TRUE
1.3.6.1.4.1.637.61.1.35.10.1:2    FALSE
1.3.6.1.4.1.637.61.1.35.10.1:43    FALSE
1.3.6.1.4.1.637.61.1.35.10.1:4    FALSE

.
.
.

Last edited by pludi; 05-17-2011 at 08:00 AM..
# 2  
Old 05-17-2011
Certainly a large data sample Smilie

Code:
for i in $(grep \: config1h.txt |cut -d \: -f1); do 
   if FOUND=$(grep $i PM09134500) ; then 
      echo "$i TRUE"
   else 
      echo "$i FALSE"
   fi
done

# 3  
Old 05-17-2011
Thank u soooo much.
I was sitting in this for many days. U made it simple ans easy. Smilie
# 4  
Old 05-17-2011
Quote:
Originally Posted by LavanyaP
Now my shell script output should be
Code:
1.3.6.1.2.1.2.2:8    TRUE
1.3.6.1.2.1.2.2:7    TRUE
1.3.6.1.4.1.637.61.1.35.11.4:4    TRUE
1.3.6.1.4.1.637.61.1.35.11.4:3    TRUE
1.3.6.1.4.1.637.61.1.35.10.1:2    FALSE
1.3.6.1.4.1.637.61.1.35.10.1:43    FALSE
1.3.6.1.4.1.637.61.1.35.10.1:4    FALSE

.
.
.
Code:
# awk -F. 'NR==FNR{if(/^1/){f=$0;next};if(/^./){a[f substr($2,2)];next}}{if(/^[0-9]/)print $0,(a[$0])?"TRUE":"FALSE"}' PM09134500 config1h.txt
1.3.6.1.2.1.2.2:8 TRUE
1.3.6.1.2.1.2.2:7 TRUE
1.3.6.1.4.1.637.61.1.35.11.4:4 TRUE
1.3.6.1.4.1.637.61.1.35.11.4:3 TRUE
1.3.6.1.4.1.637.61.1.35.10.1:2 FALSE
1.3.6.1.4.1.637.61.1.35.10.1:43 FALSE
1.3.6.1.4.1.637.61.1.35.10.1:4 FALSE
1.3.6.1.4.1.637.61.1.35.10.1:5 FALSE
1.3.6.1.4.1.637.61.1.35.10.1:20 FALSE
1.3.6.1.4.1.637.61.1.35.10.1:26 FALSE
1.3.6.1.4.1.637.61.1.35.11.2:4 FALSE
1.3.6.1.4.1.637.61.1.35.11.2:14 FALSE
1.3.6.1.4.1.637.61.1.35.11.2:19 FALSE
1.3.6.1.4.1.637.61.1.35.11.2:15 FALSE
1.3.6.1.4.1.637.61.1.35.11.2:13 FALSE
1.3.6.1.4.1.637.61.1.35.11.2:12 FALSE
1.3.6.1.4.1.637.61.1.35.10.14:3 FALSE
1.3.6.1.4.1.637.61.1.35.10.14:5 FALSE
1.3.6.1.4.1.637.61.1.35.10.14:2 FALSE
1.3.6.1.4.1.637.61.1.35.10.14:4 FALSE
1.3.6.1.4.1.637.61.1.35.10.14:6 FALSE
1.3.6.1.4.1.637.61.1.35.10.18:2 FALSE
1.3.6.1.4.1.637.61.1.35.10.19:1 FALSE
1.3.6.1.4.1.637.61.1.35.10.19:12 FALSE
1.3.6.1.4.1.637.61.1.35.10.19:11 FALSE
1.3.6.1.4.1.637.61.1.35.10.19:13 FALSE
1.3.6.1.4.1.637.61.1.35.10.19:10 FALSE
1.3.6.1.4.1.637.61.1.35.10.4:3 FALSE
1.3.6.1.4.1.637.61.1.35.10.4:2 FALSE
1.3.6.1.4.1.637.61.1.35.15.3:3 FALSE
1.3.6.1.4.1.637.61.1.35.15.3:4 FALSE
1.3.6.1.4.1.637.61.1.23.3:8 FALSE
1.3.6.1.4.1.637.61.1.23.3:3 FALSE
1.3.6.1.4.1.637.61.1.23.3:6 FALSE
1.3.6.1.4.1.637.61.1.23.3:5 FALSE
0 FALSE

Skrynesaver check your output

Last edited by danmero; 05-17-2011 at 11:45 AM..
This User Gave Thanks to danmero For This Post:
# 5  
Old 05-17-2011
Ooops, good catch, I dropped the suffix in the cut.
# 6  
Old 05-18-2011
This dint work for me. Smilie
What is that im missing here???
Code:
# nawk -F. 'NR==FNR{if(/^1/){f=$0;next};if(/^./){a[f substr($2,2)];next}}{if(/^[0-9]/)print $0,(a[$0])?"TRUE":"FALSE"}' PM00 config.txt
1.3.6.1.2.1.2.2:7 FALSE
1.3.6.1.2.1.2.2:8 FALSE
1.3.6.1.4.1.637.61.1.35.11.4:4 FALSE
1.3.6.1.4.1.637.61.1.35.11.4:3 FALSE
1.3.6.1.4.1.637.61.1.35.10.1:2 FALSE
1.3.6.1.4.1.637.61.1.35.10.1:43 FALSE
1.3.6.1.4.1.637.61.1.35.10.1:4 FALSE
1.3.6.1.4.1.637.61.1.35.10.1:26 FALSE
1.3.6.1.4.1.637.61.1.35.10.1:20 FALSE
1.3.6.1.4.1.637.61.1.35.10.1:5 FALSE
1.3.6.1.4.1.637.61.1.35.11.2:4 FALSE
1.3.6.1.4.1.637.61.1.35.11.2:13 FALSE
1.3.6.1.4.1.637.61.1.35.11.2:15 FALSE
1.3.6.1.4.1.637.61.1.35.11.2:14 FALSE
1.3.6.1.4.1.637.61.1.35.11.2:12 FALSE
1.3.6.1.4.1.637.61.1.35.11.2:19 FALSE
1.3.6.1.4.1.637.61.1.35.10.14:2 FALSE
1.3.6.1.4.1.637.61.1.35.10.14:4 FALSE
1.3.6.1.4.1.637.61.1.35.10.14:3 FALSE
1.3.6.1.4.1.637.61.1.35.10.14:5 FALSE
1.3.6.1.4.1.637.61.1.35.10.14:6 FALSE
1.3.6.1.4.1.637.61.1.35.10.18:2 FALSE
1.3.6.1.4.1.637.61.1.35.10.19:1 FALSE
1.3.6.1.4.1.637.61.1.35.10.19:11 FALSE
1.3.6.1.4.1.637.61.1.35.10.19:13 FALSE
1.3.6.1.4.1.637.61.1.35.10.19:12 FALSE
1.3.6.1.4.1.637.61.1.35.10.19:10 FALSE
1.3.6.1.4.1.637.61.1.35.10.4:2 FALSE
1.3.6.1.4.1.637.61.1.35.10.4:3 FALSE
1.3.6.1.4.1.637.61.1.35.15.3:3 FALSE
1.3.6.1.4.1.637.61.1.35.15.3:4 FALSE
1.3.6.1.4.1.637.61.1.23.3:8 FALSE
1.3.6.1.4.1.637.61.1.23.3:6 FALSE
1.3.6.1.4.1.637.61.1.23.3:5 FALSE
1.3.6.1.4.1.637.61.1.23.3:3 FALSE
0 FALSE

Im using bash shell in solaris

Last edited by Franklin52; 05-18-2011 at 03:25 AM.. Reason: Please use code tags
# 7  
Old 05-18-2011
Amending my previous script so as to preserve the suffix you get:
Code:
for i in $(grep \: config1h.txt ); do
     j=$(echo $i | cut -d \: -f1) # remove the suffix in the loop
     if FOUND=$(grep $j PM09134500) ; then
        echo "$i TRUE"
    else
        echo "$i FALSE"
    fi
done

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Comparing 2 files using awk , not getting any results - C shell

I am using c shell and trying to compare 2 files using awk . But the below awk statement doesnt give any result. Pls. advise why am not getting the desired o/p with the corrected awk script. Need to acheive this solution in awk using C shell. awk 'FNR==NR{a++;next} {for(i in a) {if ( a=$0... (8 Replies)
Discussion started by: reach2khan
8 Replies

2. UNIX for Dummies Questions & Answers

Shell script needed for comparing two files

Hi, I need shell script to compare the two files based on certain fields and output should contains the required fields based on result.pls find sample input files and required output file 1 COUNT, BNG_IP,PORT,OVLAN 22 , 10.238.60.129,1/1,2009 144 , 10.238.60.129,1/1,2251 ... (5 Replies)
Discussion started by: surender reddy
5 Replies

3. Shell Programming and Scripting

Need Help in comparing 2 text files in shell script

Hi All, I have 2 files like below vi f1 frog elephant rabit zebra dog vi f2 rabit dog ============== Now i want to comapre two files and the result will be frog (8 Replies)
Discussion started by: kumar85shiv
8 Replies

4. Shell Programming and Scripting

Need help in comparing two files using shell or Perl

I have these two file that I am trying to compare using shell arrays. I need to find out the changed or the missing enteries from File2. For example. The line "f nsd1" in file2 is different from file1 and the line "g nsd6" is missing from file2. I dont want to use "for loop" because my files... (2 Replies)
Discussion started by: sags007_99
2 Replies

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

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

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

shell script comparing files in a file

There is a text file that contains the data in the following format: COLUMN1 COLUMN2 ABC 1 ABC 2 ABC 3 DEF 4 DEF 5 XYZ 7 We have to create a second text file... (4 Replies)
Discussion started by: raina_nalin
4 Replies
Login or Register to Ask a Question