04-04-2009
35,
0
Join Date: Apr 2009
Last Activity: 16 September 2010, 11:43 AM EDT
Posts: 35
Thanks Given: 0
Thanked 0 Times in 0 Posts
Here is what i did
-bash-2.05b$ cat file1.txt
laeg.com,2/2/23,a,b,ga
aeg.com,2/2/23,a,b,ga
xyz.com,2/2/12,a,b,c
eg.com,2/2/23,a,b,ga
-bash-2.05b$ cat file2.txt
1,2,ua,xyz.com
1,2,ua,abc.com
1,2,ua,eg.com
1,2,ua,easg.com
1,2,ua,zth.com
-bash-2.05b$
-bash-2.05b$ awk -F"," 'FILENAME="file1.txt" {array[$1]=$1} FILENAME="file2.txt" { if (array[$4]) {print $0}}' file1.txt file2.txt
-bash-2.05b$ awk -F"," 'FILENAME="file1.txt" {array[$1]=$1} FILENAME="file2.txt" { if (array[$4]) {print $0}}' file1.txt file2.txt > file3.txt
-bash-2.05b$ cat file3.txt
-bash-2.05b$