Search code examples
regexfiletextnotepad++editplus

Remove long lines from text file (Notepad++/EditPlus)


I have a very big text file. Every line in this textfile has a complete sentence in it. Now I have to remove every line/sentence with more than x characters in it and just keep the lines with <=x characters.

Is this even possible? Can i do this with Notepad++/EditPlus or Regular Expressions?

Thank you for your help!


Solution

  • Using bash:

    $ awk '{if (length($0) <= x) print $0; }'  myfyle.txt
    

    Where x is the length. It will print the lines smaller than x.

    See Awk Tutorial and Introduction for more awk goodies.