I have to files. One file contains two fields:
server|user
The other files contains records with 13 fields (always 13). The fields to match on are 3 and 5, but I want to output the whole record. I have been trying this over and over with not much success, or at least inaccurate success. Here is my sample code:
while read LINE
do
echo "Searhcing for $USER......"
SERVER=`echo $LINE | awk '{print $1}'`
USER=`echo $LINE | awk '{print $2}'`
grep -i $USER *_$SERVER.mef3| grep -iv "|disabled|" >> found.txt
done < userlist
I expect to end up with a number of records equal to or less than my userlist file, but ma ending up with quite a bit more records and can't figure out why. Any help is appreciated.
I even tried doing an awk compare, but I think I got that wrong too because it didn't generate anything.
---------- Post updated at 04:05 PM ---------- Previous update was at 03:50 PM ----------
found my own solution after playing with awk a bit more. this was tons easier and faster:
awk -F\| 'NR==FNR{a[$1,$2]++;next} (a[$3,$5])' research.txt allusers.txt > found.txt