Sponsored Content
Full Discussion: Help!!!
Top Forums UNIX for Dummies Questions & Answers Help!!! Post 302475131 by ezitoc on Friday 26th of November 2010 02:51:57 PM
Old 11-26-2010
Replace columns in different files.

Hi all!

I have file1 which looks like this:

Code:
 Nº de átomos totales
          157
 Información atómica individual
NA      RX(A)             RY(A)            RZ(A)           EPSILON(eV)  SIGMA(A) Q (e)  FVX  FVY  FVZ     MOL
79    12.4923970000     0.0000000000     0.0000000000    0.00150      3.217    0.0000    0    0    0        0
79     7.4954386000     0.0000000000     0.0000000000    0.00150      3.217    0.0000    0    0    0        0
79     9.9939184000     1.4424978000     0.0000000000    0.00150      3.217    0.0000    0    0    0        0
79    12.4923970000     2.8849957000     0.0000000000    0.00150      3.217    0.0000    0    0    0        0
79     2.4984796000     0.0000000000     0.0000000000    0.00150      3.217    0.0000    0    0    0        0
79     4.9969592000     1.4424978000     0.0000000000    0.00150      3.217    0.0000    0    0    0        0
7      9.9940004349     10.0970001221     10.0670000000  0.02250      3.660    0.0000    1    1    1        1
6      9.9687515010     10.9408269779     11.2463665363  0.00512      3.905    0.0000    1    1    1        1
6      9.9946844294     10.0741408239     12.4876889268  0.00512      3.905    0.0000    1    1    1        1
.
.
(the file is longer)

And file2 which look like:

Code:
Au   12.90881    0.72125   87.57815
Au    7.91185    0.72125   87.57815
Au   10.41033    2.16375   87.57815
Au   12.90881    3.60625   87.57815
Au    2.91489    0.72125   87.57815
Au    5.41337    2.16375   87.57815
N    10.41104   10.81936   96.97897
C    11.10785   11.56856   98.02487
C    10.28173   11.54696   99.31489
.
.

What I want to do is replace columns $2 $3 and $4 from file2 into therespective columns of file1. So the final result would look like:

Code:
 Nº de átomos totales
          157
 Información atómica individual
NA      RX(A)             RY(A)            RZ(A)           EPSILON(eV)  SIGMA(A) Q (e)  FVX  FVY  FVZ     MOL
79  12.90881    0.72125   87.57815  0.00150     3.217     0.0000    0    0    0       0
79   7.91185    0.72125   87.57815  0.00150     3.217     0.0000    0    0    0       0
79  10.41033    2.16375   87.57815  0.00150     3.217     0.0000    0    0    0       0
79  12.90881    3.60625   87.57815  0.00150     3.217     0.0000    0    0    0       0
79   2.91489    0.72125   87.57815  0.00150     3.217     0.0000    0    0    0       0
79   5.41337    2.16375   87.57815  0.00150     3.217     0.0000    0    0    0       0
7   10.41104   10.81936   96.97897  0.02250     3.660     0.0000    1    1    1       1
6   11.10785   11.56856   98.02487  0.00512     3.905     0.0000    1    1    1       1
6   10.28173   11.54696   99.31489  0.00512     3.905     0.0000    1    1    1       1
.
.(the file is longer)

I hope I made my point clear and solve my problem.
Thanks a lot!!

Last edited by ezitoc; 11-27-2010 at 09:55 AM.. Reason: I have received a warning from forum
 
All times are GMT -4. The time now is 02:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy