0

I have multiple count files that look like this:

 File1.tab
 6       10      0
 49      0       53
 15      0       15
 0       0       0
 0       0       0
 0       0       0

Other file:

File2.tab
 3       1       2
 29      0       29
 4       0       4
 0       0       0
 0       0       0
 0       0       0

I have over 30 files and I want to combine the second column of each file into one big file.

I know this question have already been asked and I found a similar here How to combine column from multiple text files?

I used the answer from previous question for my problem:

paste  *.tab | awk '{i=2;while($i); {printf("%d ",$i);i+=3}printf("\n")}'

The problem is that zero values are not printed, I get something like this:

10 1

and I want something like this:

10 1
0 0
0 0
0 0
0 0
0 0

I cheked the printf format specifiers, but none works. How can I solve this problem?

Leonor
  • 53
  • 6

1 Answers1

1

You picked a bad "answer" to build on. Try this:

paste  *.tab |
awk '{for (i=2; i<=NF; i+=3) printf "%s%s", (i>2?OFS:""), $i; print ""}'
Ed Morton
  • 188,023
  • 17
  • 78
  • 185