Check Odd Number on Lines

How would you check that there are an odd number of lines in a given file? What if there was a folder of many files to check?

Questions by torikhet

Showing Answers 1 - 3 of 3 Answers

goksn

  • Jun 4th, 2009
 

We should use some scripting languages like VBScript,Javascript or perl to do this analysis.

The algorithm will go like this,

1. Open file.
2. Count number of lines (upto end of file, check n character, something like this or using any built in function)
3.Divide (no.of.lines/2) and the result is non-zero, that file contains odd number of lines
else
even number of lines.

We can repeat the steps 1 to 3 for any number of files.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions