I have a matrix(about 10,000x10,000), and I want to find the column number that contains '0'.
Matrix (test.txt) :
1 1 1 1 1 1 1 1 1 1
1 0 1 1 1 0 1 1 1 1
1 1 1 0 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
3 2 2 3 3 0 3 2 2 2
3 2 1 3 3 0 3 2 2 0
3 2 2 3 3 2 3 2 2 2
1 1 1 1 1 1 1 1 1 1
Output (example) :
2 4 6 10
I am new to LINUX SHELL, and have not found much in similar examples. Any help would be much appreciated!!
I just know how to find the row number using code: grep -nw '0' test.txt|cut -f1 -d':'
, Maybe I can transpose the matrix first(like this)? And then use the code above, right? Is there an easier way to do it?