I have two files: file 1
http://www.hello.com http://neo.com/peace/development.html, www.japan.com, http://example.com/abc/abc.html
http://news.net http://lolz.com/country/list.html,www.telecom.net, www.highlands.net, www.software.com
http://example2.com http://earth.net, http://abc.gov.cn/department/1.html
file 2:
www.neo.com/1/2/3/names.html
http://abc.gov.cn/script.aspx
http://example.com/abc/abc.html
file 2 are the search urls that is used for the partial match in file1 at column2. If it has the partial match it has to return the column 1 url with the partial match url in column 2 of file 1 like this:
Desired output:
http://www.hello.com http://neo.com/peace/development.html, http://example.com/abc/abc.html
http://news.net
http://example2.com http://abc.gov.cn/department/1.html
I am using this script which can give me exact match url pattern at column 2 but cannot work with the partial match which is as follows:
awk -F '[ \t,]' '
FNR == NR {
a[$1]
next
}
{ o = $1
c = 0
for(i = 2; i <= NF; i++)
if($i in a)
o = o (c++ ? ", " : "\t") $i
print o
}' file2 file1
The output is :
http://www.hello.com http://example.com/abc/abc.html
http://news.net
http://example2.com
Any suggestion to fix this ?