Sample Header Ad - 728x90

Rounding many values in a csv to 3 decimals (printf ?)

5 votes
3 answers
1075 views
I have a paste command like this paste -d , file1.csv file2.csv file3.csv And file2.csv contains numbers like this
0.2
0.3339
0.111111
I want the values in file2.csv having 3 decimals like this:
0.200
0.334
0.111
For one value this is working: printf "%.3f" "0.3339" -> 0.334 But for multiple values in file2.csv this is not working: paste -d , file1.csv <(printf %s "%.3f" "$(< file2.csv)") file3.csv Maybe there is a good solution?
Asked by R 9000 (167 rep)
Feb 24, 2023, 12:21 AM
Last activity: Feb 28, 2023, 11:10 PM