Skip to main content
added 37 characters in body
Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 117

You could use awk to split each group of data (where those are between NA lines) into separate files and skipping NA lines, then paste them together.

awk '/^NA$/ && !NA{N++; NA=1; next} !/^NA$/{print >"file"N; NA=0}
    END{system("paste file*")}' inile.txt

The NA flag is used to create files in sequencial order, we could use below instead.

awk '/^NA$/{N++; next} !/^NA$/{print >"file"N}
    END{system("paste file*")}' inile.txt

The output is:

4 3 2
3 4 7
5 5 4
7 2 6
8   9
3

You could use awk to split each group of data into separate files and skipping NA lines, then paste them together.

awk '/^NA$/ && !NA{N++; NA=1; next} !/^NA$/{print >"file"N; NA=0}
    END{system("paste file*")}' inile.txt

The NA flag is used to create files in sequencial order, we could use below instead.

awk '/^NA$/{N++; next} !/^NA$/{print >"file"N}
    END{system("paste file*")}' inile.txt

The output is:

4 3 2
3 4 7
5 5 4
7 2 6
8   9
3

You could use awk to split each group of data (where those are between NA lines) into separate files and skipping NA lines, then paste them together.

awk '/^NA$/ && !NA{N++; NA=1; next} !/^NA$/{print >"file"N; NA=0}
    END{system("paste file*")}' inile.txt

The NA flag is used to create files in sequencial order, we could use below instead.

awk '/^NA$/{N++; next} !/^NA$/{print >"file"N}
    END{system("paste file*")}' inile.txt

The output is:

4 3 2
3 4 7
5 5 4
7 2 6
8   9
3
added 9 characters in body
Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 117

You could use awk to split each group of data into separate files and skipping NA lines, then paste them together.

awk '/^NA$/ && !NA{N++; NA=1; next} !/^NA$/{print >"file"N; NA=0}
    END{system("paste file*")}' inile.txt

The NA flag is used to create files in sequencial order, we could use below instead.

awk '/^NA$/{N++; next} !/^NA$/{print >"file"N}
    END{system("paste file*")}' inile.txt

The output is:

4 3 2
3 4 7
5 5 4
7 2 6
8   9
3

You could use awk to split each group of data into separate files, then paste them together.

awk '/^NA$/ && !NA{N++; NA=1; next} !/^NA$/{print >"file"N; NA=0} END{system("paste file*")}' inile.txt

The output is:

4 3 2
3 4 7
5 5 4
7 2 6
8   9
3

You could use awk to split each group of data into separate files and skipping NA lines, then paste them together.

awk '/^NA$/ && !NA{N++; NA=1; next} !/^NA$/{print >"file"N; NA=0}
    END{system("paste file*")}' inile.txt

The NA flag is used to create files in sequencial order, we could use below instead.

awk '/^NA$/{N++; next} !/^NA$/{print >"file"N}
    END{system("paste file*")}' inile.txt

The output is:

4 3 2
3 4 7
5 5 4
7 2 6
8   9
3
Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 117

You could use awk to split each group of data into separate files, then paste them together.

awk '/^NA$/ && !NA{N++; NA=1; next} !/^NA$/{print >"file"N; NA=0} END{system("paste file*")}' inile.txt

The output is:

4 3 2
3 4 7
5 5 4
7 2 6
8   9
3