Hi all,
I am really in need of some light here. Any suggestions deeply appreciated !
I have a relative simple problem but there is something missing.
This is the task: I have a file with N lines. N is composed of M subgroups. For instance, let's say that each subgroup has 3 lines :
Line 1 : A1 (A1 is actually composed by a few columns)
Line 2 : A2
Line 3 : A3
Line 4 : B1
Line 5 : B2
Line 6 : B3
...
Line N : 3xM
I just need to filter this file and put every n-th line in a different file :
File 1
Line 1 : A1
Line 2 : B1
Line 3 : C1
...
File 2
Line 1 : A2
Line 2 : B2
Line 3 : C2
...
File 3
Line 1 : A3
Line 2 : B3
Line 3 : C3
...
Initially I tried to use "sed -n" like this :
sed -n '1,${p;n;n;}' data > result
This works only for small subgroups like the one above. If data has millions of lines with thousands of subgroups, it is impossible to run sed command (because it has thousands of "n;n;n...").
Does someone know how to perform an efficient selective printing ?
Thanks !