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!
This is solution for Notepad++
Choose "Regular expression" in Search Mode. Make sure ". matches newline" checkbox is unchecked.
Find what: .{x}.+
Replace with: (empty)
If you don't want to leave an empty line after replacement:
Find what: .{x}.+(\r?\n|\n|$)
Replace x with number of your choice.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With