1

I am using a unix based program. I want to automate the code so as not to copy and paste data one by one. For this, I need to define line-by-line data in a file as a variable for the code

The program converts xyz coordinates to local coordinates. How can I run the coordinates in the xyz_coordinates file I created, one by one, in the code below? In the program I use, the conversion code works like this:

echo 4208830.039709186 2334850.551667509 4171267.377406844 -6.753E-01 4.493E-01 2.849E-01  | xyz2env.py

and this is the file i am trying to run:

2679689.926729193 -727950.9964290063 5722789.538975053 7.873E-02 3.466E-01 6.410E-01

2679689.927123377 -727950.9971557076 5722789.540522 7.912E-02 3.458E-01 6.425E-01

2679689.930567728 -727950.9979971027 5722789.550832021 8.257E-02 3.450E-01 6.528E-01

2679689.931029495 -727950.9992263148 5722789.549927638 8.303E-02 3.438E-01 6.519E-01

2679689.929031829 -727950.9981009626 5722789.546359798 8.103E-02 3.449E-01 6.484E-01

........ 

and it goes on like this. Also, there are spaces between the lines. Will this be a problem?

Antoine
  • 1,393
  • 4
  • 20
  • 26

1 Answers1

0

You can use xargs to invoke the command for a specific number of arguments (6 in your case) and have the advantage of skipping empty lines automatically

< file.txt xargs -n 6 xyz2env.py
Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134