I want to perform a simple calculation on each number in a column of whitespace delimited data using Bash utilities such as cut and bc. The data may look like something such as the following:
string 0.998663 string string string
string 0.998592 string string string
string 0.999096 string string string
Let's say I want to change the show the numbers in the second column to three significant figures. I want to add another column of these new numbers to this data directly following the second column. So, the result may look like something such as the following:
string 0.998663 0.999 string string string
string 0.998592 0.999 string string string
string 0.999096 0.999 string string string
I know that I can manually cycle through all of this data and then construct new columns of data, but I imagine that there is a more efficient way of doing this. Would you happen to know of some clever way of doing this?