Find the answer to your Linux question:
Results 1 to 3 of 3

Thread: Decimal points

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Decimal points

    Hello guys

    I need to find a way to modify my file so I have my first number with 3 decimal points, comma, space and then my second number 3 decimal points too.

    This is an example of my file:

    And I need this output:
    12.000, 10.026
    8.000, 6.350
    5.000, 5.830
    11.000, 7.870

    I think I can use something like: printf "%0.3f\n"
    but how can I create a script that can read the whole file and save it in the output format I need?

    Thanks a lot for your help

  2. #2
    You could use awk.
    awk -F\, {printf("%.3f, %.3f\n",$1,$2)}' yourfile

  3. #3
    That works great!

    Thanks a lot!!

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts