troubleshooting Question

Overwriting part of one file with part of another file using unix script or perl

Avatar of libertyforall2
libertyforall2Flag for United States of America asked on
Linux OS DevPowershellPerl
3 Comments1 Solution348 ViewsLast Modified:
Ok. I have one file that is updated with new numbers and I need to copy the data from file 1 and replace part of file 2 with the new numbers in file 1. I have attached file1 & file2 in their entirety. Basically if I have this below


2.4583E+07
1.3956E+03
5.39583E+07
1.2583E+05
5.39583E+07
4.3933E+05
5.39583E+06
7.1183E+07
1.07917E+08
4.85625E+09
1.3E+08
4.3E+08
7.5E+33
2.3E+08
4.3E+07
3.2E+05
2.3E+07
5.3E+08
4.6E+06
2.7E+10

The script needs to search for the part of the script below then replace only the data in column 5 (I believe its 5 but perhaps the script should check for the first characters that contain E+) with the new data above but only the portion above. Nothing else needs to be changed.

  echo "19.39 -155.100 50.0 5.39583E+07 300.0" >>CONTROL
  echo "19.39 -155.101 100.0 5.39583E+07 300.0" >>CONTROL
  echo "19.39 -155.102 150.0 5.39583E+07 300.0" >>CONTROL
  echo "19.39 -155.103 170.0 5.39583E+07 300.0" >>CONTROL
  echo "19.39 -155.104 190.0 5.39583E+07 300.0" >>CONTROL
  echo "19.39 -155.105 210.0 5.39583E+07 300.0" >>CONTROL
  echo "19.39 -155.106 230.0 5.39583E+07 300.0" >>CONTROL
  echo "19.39 -155.107 250.0 5.39583E+07 300.0" >>CONTROL
  echo "19.39 -155.108 270.0 1.07917E+08 300.0" >>CONTROL
  echo "19.39 -155.109 300.0 4.85625E+09 300.0" >>CONTROL
  echo "19.401391 -155.280640 50.0 2.3E+08 100.0" >>CONTROL
  echo "19.401391 -155.280740 150.0 2.3E+08 100.0" >>CONTROL
  echo "19.401391 -155.280840 300.0 2.3E+08 100.0" >>CONTROL
  echo "19.401391 -155.280940 350.0 2.3E+08 100.0" >>CONTROL
  echo "19.401391 -155.281040 400.0 2.3E+08 100.0" >>CONTROL
  echo "19.401391 -155.281140 450.0 2.3E+08 100.0" >>CONTROL
  echo "19.401391 -155.281240 550.0 2.3E+08 100.0" >>CONTROL
  echo "19.401391 -155.281340 600.0 2.3E+08 100.0" >>CONTROL
  echo "19.401391 -155.281440 650.0 4.6E+08 100.0" >>CONTROL
  echo "19.401391 -155.281540 700.0 2.07E+10 100.0" >>CONTROL
file1.txt
file2.txt
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros