Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare two files or arrays

Status
Not open for further replies.

rkckjk

IS-IT--Management
Apr 27, 2001
34
US
I created two arrays or files that I want to compare. I want the output to show what's different from fileA vs. fileB and what's different from fileB vs. fileA. I would like this be done without using temp files. Here is what I have coded thus far:

#!/usr/bin/ksh

typeset -i x=0
typeset -i y=0

FSTAB_LST=`cat /etc/fstab | sort | awk '{ print $1 }' |
sed -e "/^$/d" -e "/^#/d" -e "s|/.../||g" -e "s|/dev/||g" -e "s|..ss:..../||g" -e "/vgswap/d"`

BDF_LST=`bdf | tail +2 | sort | awk '{ print $1 }' |
sed -e "/^[0-9]/d" -e "s|/.../||g" -e "/^$/d" -e "s|..ss:..../||g"`



if [ "$FSTAB_LST" = "$BDF_LST" ]
then
print "The BDF & FSTAB Lists Match"
exit
else
print "***** BDF & FSTAB Error Listing"


for F_CNT in $FSTAB_LST
do
FSTAB_CNT[y]=$F_CNT
y=y+1
done

for B_CNT in $BDF_LST
do
BDF_CNT[x]=$B_CNT
x=x+1
done
fi
 
I think it can be done easier with 'comm' - your miliage may vary though.

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
I already tried using comm, but it doesn't seem to work. I get messages stating: comm: cannot open
 
well..... tried digging in WHY it wasn't working?
[might be 'pilot error'].

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top