-
Comparing Files.
Hey guys,
I have 30 files full of mac addresses. What do you think would be the best way to compare all these files and output the mac addresses that show up in all 30 files to a new file. Is there a compare function? Should I read them into arrays and compare them? Any ideas would help out, I am a newbie to C but understand the basics. Thanks
-
http://cboard.cprogramming.com/showthread.php?t=56543
Or is this a slightly different problem?
If the files are text files, one MAC address per line, then I can do this using a 2-line AWK program
Code:
{ count[$1]++ }
END { for ( i in count ) if ( count[i] == 30 ) print i
Save that as a file called program.
Then do
Code:
awk -f program mac_file*.txt
-
Yes it is the same question, I forgot I asked here already. Thanks for your reply. I like your way of doing it.
-
I would suggest separating each MAC address by strings, and using the function strcmp() to compare. If you dont know how to do this specifically, the FAQ should have all the info you need. If it doesn't, post again and I will do what I can
[edit]
Ahhh! Curses! :D
[/edit]