I have a file full of expressions like this:0.100000000000000000000*10^(1) 0.000000000000000000000*10^(0)0.911403977421716024142*10^(-15) 0.983917614423065751378*10^(-15)and I would like to evaluate each term and round the value to 2 decimal points to get:1.00 0.000.00 0.00Using bc -l on each token seperated by white space would accomplish the first step, but I don't know how to do this. Moreover, there is the issue with rounding.Any suggestions are welcome!FYI: There are three types of lines in the file. Those which are empty, those which contain a single integer and those which are of the form demonstrated above.
Evaluating and rounding a file of numbers in scientific form
regular expression;replace
You can use substitute feature with a submatch and system function like so:%s/\([^ ]\+\)/\=system('printf %.2f $(echo scale=2; ' . submatch(1) . ' | bc -l)')/g   this performs a substitute on whole file (%).\([^ ]\+\) - matches every string stream which doesn't contain space.Then we replace all occurrences with an expression \= that's after it.system() runs shell script/command and returns it's output.printf %.2f $(echo scale=2; ' . submatch(1) . ' | bc -l) - submatch(1) returns result of our match - so every math expression and whole is processed as a shell command.