How can I delete all but every fourth line in a text file?

0 votes
asked Oct 22, 2009 by jacob

I have a log that looks like this:

line 1
line 2
line 3
line 4
line 1
line 2
line 3
line 4

How can I use AHK to delete lines 1, 2, and 3, but skip the fourth, and then continue to loop?

2 Answers

0 votes
answered Oct 22, 2009 by robert-massaioli

Your using the wrong tool for the job. (Not to mention that how to use software is a superuser.com question)

The solution is to open up a terminal and type:

tail -n+4 yourFileWithLines

That will work perfectly. On windows install cygwin to get tail. (<== That could almost be a twss joke)

0 votes
answered Oct 22, 2009 by codism

This is not the direct answer you are expecting, but if you install cygwin (I guess you are working in Windows) and try grep & less. You will soon realize they are the right tool for your purpose.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter

...