I am having a file with numbers in MB units and I wanted to make them in GB then I found a very interesting perl to do this
perl -pe 's{(?<!\d)(\d+(?:\.\d+)?)(?!\d)}{$1/1024}ge'
But I still need to round the results 2 digits after the dot
Currently, results like 260.676914215088
I tried some other Unix tools like cut
and bc
but it would be better if done within Perl.
BTW the file contains numbers and strings and the above Perl is working as expected but I still need to round results.
I would appreciate if someone helped with the above perl statement as I am already using it to change between different units