I am meeting some difficulties when using bash to insert multiple empty lines into a file (called file1) according to an index file(called file2). (these files can be treated as passed variables) the index file (file2) looks like:
-
-
-
M
H
A
-
N
X
X
M
-
-
-
F
G
A
...
the file1 looks like this:
M x1 y1 z1 m1 n1
H x2 y2 z2 m2 n2
A x3 y3 z3 m3 n3
N x4 y4 z4 m4 n4
X x5 y5 z5 m5 n5
X x6 y6 z6 m6 n6
M x7 y7 z7 m7 n7
F x8 y8 z8 m8 n8
G x9 y9 z9 m9 n9
A x0 y0 z0 m0 n0
...
the output should be looks like this:
-
-
-
M x1 y1 z1 m1 n1
H x2 y2 z2 m2 n2
A x3 y3 z3 m3 n3
-
N x4 y4 z4 m4 n4
X x5 y5 z5 m5 n5
X x6 y6 z6 m6 n6
M x7 y7 z7 m7 n7
-
-
-
F x8 y8 z8 m8 n8
G x9 y9 z9 m9 n9
A x0 y0 z0 m0 n0
...
if file2 deletes the '-', the content as well as the order will always be the same as the first column in file1.
I tried dataframe in Python to deal with it, but it's too slow. So I was wondering how to use bash to figure this out. Thanks!