0

I have a file where I have data in 3-line sets. I want the 2nd and 3rd line from each set. How do I get that?

For an example from: [set no][no of line in set]

11
12
13
21
22
23
31
32
33

I want:

12
13
22
23
32
33

and so on.

I have tried a few options but have been unsuccessful.

2
  • What have you tried, what else is to be found on the lines. Are the files just repeating like that so one can say you need every second and third line?
    – FelixJN
    Aug 24, 2015 at 8:34
  • 1
    sed '1~3d' will output each second and third lines
    – Costas
    Aug 24, 2015 at 8:35

1 Answer 1

2

With POSIX awk:

awk '!(FNR%3==1)' <file

With POSIX sed:

sed -e '1d;n;n;d' <file

With GNU sed:

sed -e '1~3d' <file

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .