Table to Matrix

Hi,

I have a table in the format:
1 0 -1 1 0
2 0 1 -1 0 0 0
3 0 1 1 0 0 0 0 0 0

etc.
I am trying to input this to a program, however it is complaining about the fact that it is not in matrix format. How do I add 0's to end of the rows to make them even?

Thanks in advance!

Try

awk '{if(NF>max) max=NF} END{while(getline<"file"){for(i=NF+1;i<=max;i++)$i="0";print}}' file
1 Like

:b: Thanks, worked!