

InterviewSolution
1. |
Solve : help please - identification of duplicates? |
Answer» I need to find to find duplicate lines in a document and then print the line numbers of the duplicates aside from spliting the file into a series of one line files and then comparing (which seems very low tech) I don't know how to do thisAh, but that's exactly what must be done! Psuedo-code: Code: [Select]OPEN file for reading -> file descriptor one Open file for reading -> file descriptor two Repeat until EOF -> file descriptor one: Read next line -> file descriptor one Repeat until EOF -> file descriptor two: Read next line -> file descriptor two Compare lines; if matching, say so End Repeat End RepeatYou can do this with any of a variety of scripting methods. Unix gurus would probably do it in pure awk/sed. I'm more COMFORTABLE in PHP, so that's what I would use. I can also do this in awk, but it would take me longer to write the script. Do you have a PHP parser on the system in question? (The PHP solution would also be the easiest to understand, IMO.) |
|