-1

I have Following type of data: each block starting with "Atom An X Y Z", I have 4 rows and 5 columns for each number point. I can arrange somehow for 3 columns and 2 rows with following code. awk '!(NR%2){for (i=1;i<=NF-2;i=i+3){print a[i], a[i+1], a[i+2]; print $i, $(i+1), $(i+2)}} {split($0,a)}' file But couldn't able to extend to more columns and rows.

                  1                   2                       3

Atom   An   X      Y      Z       X      Y      Z        X     Y     Z

1      6   0.1  -0.00  -0.20   -0.08  -0.03  -0.03    -0.04  -0.06  -0.01 

2      1  -0.10 -0.31   0.00   -0.04  -0.03  -0.03    -0.10   0.14  -0.14

3     61   0.06   0.04   0.04   0.00   0.62   0.33    -0.11  -0.03  -0.02

                   4                     5                     6

Atom   An   X      Y      Z       X      Y      Z        X     Y     Z

1      6   -0.15  -0.00  -0.00   -0.09  -0.01   0.08   -0.00   0.03   0.00 

2      1   -0.14  -0.01  -0.01   -0.08  -0.07  -0.01   -0.03  -0.07  -0.01

3     61   -0.11   0.01  -0.04   -0.03  -0.07  -0.01    0.15  -0.01   0.07

I want to arrange like is:

                  1                  

Atom   An   X      Y      Z     

1      6   0.1  -0.00  -0.20   

2      1  -0.10 -0.31   0.00   

3     61   0.06   0.04   0.04  
                   2                 

Atom   An       X      Y      Z   

1      6    -0.08  -0.03  -0.03  

2      1    -0.04  -0.03  -0.03  

3     61     0.00   0.62   0.33   

                   3

Atom   An    X     Y     Z

1      6    -0.04  -0.06  -0.01 

2      1    -0.10   0.14  -0.14

3     61    -0.11  -0.03  -0.02

                   4        

Atom   An   X      Y      Z    

1      6   -0.15  -0.00  -0.00  

2      1   -0.14  -0.01  -0.01 

3     61   -0.11   0.01  -0.04 

                   5             

Atom   An   X      Y      Z     

1      6   -0.09  -0.01   0.08  

2      1  -0.08   -0.07  -0.01  

3     61  -0.03   -0.07  -0.01   

                    6

Atom   An     X     Y     Z

1      6   -0.00   0.03   0.00 

2      1   -0.03  -0.07  -0.01

3     61    0.15  -0.01   0.07

migration rejected from serverfault.com Apr 26 at 1:55

This question came from our site for system and network administrators. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as unclear what you're asking by αғsнιη, Mr Shunz, Anthony Geoghegan, garethTheRed, Sparhawk Apr 26 at 1:55

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • @Theophrastus I have modified my question, Please have a look at this. Actually, for each points (1, 2, 3,4, 5, 6) there is set of coordinates (X, Y, Z). I want to rearrange points in a single column. with awk '{print $1,$2,$3,$4}, I can grep different column but further arrange, I couldn't been able to manage. Thank for your attention. – Aman Apr 15 at 10:42
  • is that your actual file format (because you do edit on numbers formatting)? I mean only in 2 blocks? if no, so how many columns and rows each block (blocks that starting with Atom An X Y Z …. as header ) ? also let's us know what have you tried and in what area we can help you? – αғsнιη Apr 15 at 10:45
  • @αғsнιη, well, in above example, each block starting with "Atom An X Y Z", I have 4 rows and 5 columns for each number point. I can arrange somehow for 3 columns and 2 rows with following code. awk '!(NR%2){for (i=1;i<=NF-2;i=i+3){print a[i], a[i+1], a[i+2]; print $i, $(i+1), $(i+2)}} {split($0,a)}' file But couldn't able to extend to more columns and rows. – Aman Apr 15 at 11:03
  • You should clearly explain the problem in the question body itself. Comments are designed with the intent that other users can make suggestions or ask for clarification. – Anthony Geoghegan Apr 24 at 11:07

Browse other questions tagged or ask your own question.