I am trying to edit a document of 20000 lines. I have to remove every odd line, say for example:
Apple Monkey Orange Lion fruit animal
How can I remove every odd line's characters in the document?
You can do it with find and replace:
\n(Unix, OS X) or
\r\n(Windows) to match end of line, or just use
\Rwhich should work everywhere (thanks for @Aurel Bílý)
\n|$is needed to have correct result even at the end of the file
.+ : 1 or more any character but newline \R : any kind of linebreak (ie. \r, \n, \r\n) ( : start group 1 .+ : 1 or more any character but newline ) : end group 1
. matches newline
Result for given example:
Monkey Lion animal
Basically perform the action once to remove an odd line, then get the program to repeat the action to the end of the file. This can be used to solve many problems!