[Solved] Multiply text file in Unix by a constant


This might be close, using Perl:

perl -pe 's/([+-]?[0-9.]+)/$1*19.123456789123/ge' YourFile

Sample Output

-4894.92001617493 
-4894.96925301402 
-4914.3031850202 
-4952.55012214707 
-4971.67357651707

That kind of says… “capture anything that starts with an optional plus or minus and has a bunch digits and decimal points and call it capture group 1. Replace that with whatever it was multiplied by your magic number. The e at the end, says to evaluate the right side as an expression rather than take it as a literal. The g at the end says to do it each and every time it occurs on each line, rather than just the first time.”

1

solved Multiply text file in Unix by a constant