I have a certain folder with several files, and these in turn, contains in its interior description of Cartesian X and Y coordinate points.
However, I want to replace these points automatically and dynamically, ie use while
to run all those files by running sed
to change the X and Y axis values of the files.
Well, what becomes the crucial point here is to do the insertion coming from an adder / counter until all the files contained in the folder have finished.
The detail is that, for every 5 (five) files, the Y must receive identical values, and the next 5 files, a new number is added giving a jump from 0 - 5. See example:
list of the first 5 files:
X: 100 Y: 0
X: 200 Y: 0
X: 300 Y: 0
X: 400 Y: 0
X: 500 Y: 0
list of next 5 files:
X: 600 Y: 5
X: 700 Y: 5
X: 800 Y: 5
X: 900 Y: 5
X: 1000 Y: 5
list of the following 5 files:
X: 1100 Y: 10
X: 1200 Y: 10
X: 1300 Y: 10
X: 1400 Y: 10
X: 1500 Y: 10
I think you have already understood the logic all right! The points are being summed by integers to a counter, which puts them in the measure of an input of 5 files at a time, starting with the number 100 for the X axis, and soon after the second X of the second file to 200, and for the third file 300, fourth file X400, and fifth file with X500 axis.
Continue by calculating / adding 100 in 100 and adding 5 files in the next, and this is done for every 5 cycles of files. This is for the X axis, and for the Y, it would be almost the same thing, however we must take into account the value is smaller, being 5 in 5 considering that it should set the same value for the first 5 files and do it again the sum for the next 5 files and etc ...
Example
#!/bin/sh
X=100;
Y=0;
while [ $Y -lt 5 ]; do
echo -e "X: $X\r";
echo -e "Y: $Y\n";
let X=$X+1;
let Y=$Y+1;
done
Follow the result after running the script