75
18
I've got a rather sizable CSV file (75MB). I'm just trying to produce a graph of it, so I really don't need all of the data.
Rewording: I'd like to delete n lines, then keep one line, then delete n lines, and so on.
So if the file looked like this:
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
and n=2, then the output would be:
Line 3
Line 6
It seems like sed
might be able to do this, but I haven't been able to figure out how. A bash command would be ideal, but I'm open to any solution.
2Do you really want lines 1, 3, 6, etc., rather than 1, 4, 7, etc.? – Ilmari Karonen – 2012-03-03T18:59:06.423
2Since it is a CSV file, I assume the first line contains meta data (i.e. field names.). If so, the question should be "every nth line after the first". – iglvzx – 2012-03-03T19:57:49.243
Oops. Can't believe I did that. – Computerish – 2012-03-03T21:38:20.623
81, 3, 6 still doesn't make sense! – wim – 2012-03-05T00:18:56.353
1I guess it should be 1, 3, 5 unless n=2 is a magic value for triangular numbers (1, 3, 6, 10, 15, 21 etc.) – rjmunro – 2012-03-07T10:32:26.417
5Can you update your question to make what you're asking for ("every nth line", "n=2") and your desired output (Line 3, Line 6) consistent? Future readers are going to be confused. – Keith Thompson – 2012-03-08T04:56:24.017