I have some raw data in one file say File1.txt
Colt McCoy QB CLE 135 222 1576 6 9 60.8% 74.51
Josh Freeman QB TB 291 474 3451 25 6 61.4% 95.9
Matt Cassel QB KC 262 450 3116 27 7 58.2% 93.0
Michael Vick QB PHI 233 372 3018 21 6 62.6% 100.2
Matt Schaub QB HOU 365 574 4370 24 12 63.6% 92.0
File 2.txt has a list of names, one name per line
Josh
Matt
I want to get the output as Name and line number. For the above example it would be:
Josh: 2
Matt: 3,5
I have a command which gives me the list of names and the line numbers but I want to print it in the desired format above. My current command is
awk '{print $1, NR}' file1.txt | grep -f file2.txt
It shows
Josh 2
Matt 3
Matt 5
What can I do to make it print like the desired format?