- Date: 2020/12/12 17:19
- Name: Naoya Yamaguchi
- Hi,
When you take the sum of "example.PDOS.Tetrahedron.atom1" and "example.PDOS.Tetrahedron.atom3", you can do it as follows, for example: $ paste example.PDOS.Tetrahedron.atom1 example.PDOS.Tetrahedron.atom3 | awk -v num_columns=5 '{for (j=2; j<=num_columns; j++) columns[j]=0; for (i=1; i<=NF; i+=num_columns) {for (j=2; j<=num_columns; j++) columns[j]+=$(i+j-1);} printf $1; for (j=2; j<=num_columns; j++) printf " %17.15f", columns[j]; print ""}'
When adding "example.PDOS.Tetrahedron.atom5", you can add "example.PDOS.Tetrahedron.atom5" to arguments of the "paste" command. $ paste example.PDOS.Tetrahedron.atom1 example.PDOS.Tetrahedron.atom3 example.PDOS.Tetrahedron.atom5 | awk -v num_columns=5 '{for (j=2; j<=num_columns; j++) columns[j]=0; for (i=1; i<=NF; i+=num_columns) {for (j=2; j<=num_columns; j++) columns[j]+=$(i+j-1);} printf $1; for (j=2; j<=num_columns; j++) printf " %17.15f", columns[j]; print ""}'
Regards, Naoya Yamaguchi
|