1

I am looking for a program that can find the longest line of a .txt file. It should run on Microsoft Windows. Any license or price is fine.

2
  • How many characters shall a tab count? Just 1, 4 or 8 or customizable? Jan 23, 2017 at 10:18
  • @Walmart - I think that your answers above should be put into an answer rather than left as comments. Jan 23, 2017 at 16:27

2 Answers 2

5

I am looking for a program that can find the longest line of a .txt file. It should run on Microsoft Windows.

I've listed two FREE solutions below that may suffice for your need.

Method 1

You could use: wc -L "c:\folder\file.txt" from the CoreUtils for Windows for example if you just need the number of the length of the longest line in that file. This would be a freebie too by the way.


Method 2

You can do this in Windows with PowerShell as well for a particular file:

  1. Get the maximum length number of a record in a file:

    GC "c:\folder\file.txt" | Measure -Property length -Maximum | Select Maximum

  2. Get the content of the longest line/record in a file

    GC "c:\folder\file.txt" | Sort -Property length | Select -last 1


Further Resources

1
  • 1
    I would like to mention that if the file contains CTL language scripts like Devanagari, then use following command: GC "c:\folder\file.txt" -Encoding UTF8 | Sort -Property length | Select -last 1
    – ePandit
    Sep 30, 2017 at 16:27
0

You can add an extension to Notepad++ to perform this operation. See this answer on SuperUser for details

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.