Format the number of decimal points

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I want to slice the 5th column down to three decimal points and put it with first column.



Input



 Accuracy Precision Recall F-measure s.d
bemkl_J_DIFP 0.6001 0.01545 0.4304 0.02984 0.016098
bemkl_J_DI 0.6011 0.01390 0.3870 0.02684 0.013959
bemkl_J_FP 0.4831 0.01424 0.3609 0.02740 0.015979


OutputFile



 Accuracy Precision Recall F-measure
bemkl_J_DIFP 0.6001(0.016) 0.01545 0.4304 0.02984
bemkl_J_DI 0.6011(0.013) 0.01390 0.3870 0.02684
bemkl_J_FP 0.4831(0.015) 0.01424 0.3609 0.02740


Command:



awk -F" " '$6>0 print substr($6,1,5)' filename| awk 'print "("$0")"'









share|improve this question























  • awk -F" " '$6>0 print substr($6,1,5)' filename
    – KHAN irfan
    Oct 10 '17 at 0:59










  • As you're using AWK in your comment, note that printf "%.3f", $6 actually cuts the field down to three decimal places, regardless of how many digits are before the point, unlike substr
    – Fox
    Oct 10 '17 at 1:17










  • I think you mean the 6th column - not the 5th column
    – fpmurphy1
    Oct 10 '17 at 3:04














up vote
0
down vote

favorite












I want to slice the 5th column down to three decimal points and put it with first column.



Input



 Accuracy Precision Recall F-measure s.d
bemkl_J_DIFP 0.6001 0.01545 0.4304 0.02984 0.016098
bemkl_J_DI 0.6011 0.01390 0.3870 0.02684 0.013959
bemkl_J_FP 0.4831 0.01424 0.3609 0.02740 0.015979


OutputFile



 Accuracy Precision Recall F-measure
bemkl_J_DIFP 0.6001(0.016) 0.01545 0.4304 0.02984
bemkl_J_DI 0.6011(0.013) 0.01390 0.3870 0.02684
bemkl_J_FP 0.4831(0.015) 0.01424 0.3609 0.02740


Command:



awk -F" " '$6>0 print substr($6,1,5)' filename| awk 'print "("$0")"'









share|improve this question























  • awk -F" " '$6>0 print substr($6,1,5)' filename
    – KHAN irfan
    Oct 10 '17 at 0:59










  • As you're using AWK in your comment, note that printf "%.3f", $6 actually cuts the field down to three decimal places, regardless of how many digits are before the point, unlike substr
    – Fox
    Oct 10 '17 at 1:17










  • I think you mean the 6th column - not the 5th column
    – fpmurphy1
    Oct 10 '17 at 3:04












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I want to slice the 5th column down to three decimal points and put it with first column.



Input



 Accuracy Precision Recall F-measure s.d
bemkl_J_DIFP 0.6001 0.01545 0.4304 0.02984 0.016098
bemkl_J_DI 0.6011 0.01390 0.3870 0.02684 0.013959
bemkl_J_FP 0.4831 0.01424 0.3609 0.02740 0.015979


OutputFile



 Accuracy Precision Recall F-measure
bemkl_J_DIFP 0.6001(0.016) 0.01545 0.4304 0.02984
bemkl_J_DI 0.6011(0.013) 0.01390 0.3870 0.02684
bemkl_J_FP 0.4831(0.015) 0.01424 0.3609 0.02740


Command:



awk -F" " '$6>0 print substr($6,1,5)' filename| awk 'print "("$0")"'









share|improve this question















I want to slice the 5th column down to three decimal points and put it with first column.



Input



 Accuracy Precision Recall F-measure s.d
bemkl_J_DIFP 0.6001 0.01545 0.4304 0.02984 0.016098
bemkl_J_DI 0.6011 0.01390 0.3870 0.02684 0.013959
bemkl_J_FP 0.4831 0.01424 0.3609 0.02740 0.015979


OutputFile



 Accuracy Precision Recall F-measure
bemkl_J_DIFP 0.6001(0.016) 0.01545 0.4304 0.02984
bemkl_J_DI 0.6011(0.013) 0.01390 0.3870 0.02684
bemkl_J_FP 0.4831(0.015) 0.01424 0.3609 0.02740


Command:



awk -F" " '$6>0 print substr($6,1,5)' filename| awk 'print "("$0")"'






shell-script text-formatting numeric-data






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 10 '17 at 23:38

























asked Oct 10 '17 at 0:42









KHAN irfan

83




83











  • awk -F" " '$6>0 print substr($6,1,5)' filename
    – KHAN irfan
    Oct 10 '17 at 0:59










  • As you're using AWK in your comment, note that printf "%.3f", $6 actually cuts the field down to three decimal places, regardless of how many digits are before the point, unlike substr
    – Fox
    Oct 10 '17 at 1:17










  • I think you mean the 6th column - not the 5th column
    – fpmurphy1
    Oct 10 '17 at 3:04
















  • awk -F" " '$6>0 print substr($6,1,5)' filename
    – KHAN irfan
    Oct 10 '17 at 0:59










  • As you're using AWK in your comment, note that printf "%.3f", $6 actually cuts the field down to three decimal places, regardless of how many digits are before the point, unlike substr
    – Fox
    Oct 10 '17 at 1:17










  • I think you mean the 6th column - not the 5th column
    – fpmurphy1
    Oct 10 '17 at 3:04















awk -F" " '$6>0 print substr($6,1,5)' filename
– KHAN irfan
Oct 10 '17 at 0:59




awk -F" " '$6>0 print substr($6,1,5)' filename
– KHAN irfan
Oct 10 '17 at 0:59












As you're using AWK in your comment, note that printf "%.3f", $6 actually cuts the field down to three decimal places, regardless of how many digits are before the point, unlike substr
– Fox
Oct 10 '17 at 1:17




As you're using AWK in your comment, note that printf "%.3f", $6 actually cuts the field down to three decimal places, regardless of how many digits are before the point, unlike substr
– Fox
Oct 10 '17 at 1:17












I think you mean the 6th column - not the 5th column
– fpmurphy1
Oct 10 '17 at 3:04




I think you mean the 6th column - not the 5th column
– fpmurphy1
Oct 10 '17 at 3:04










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










$ cat 1.awk
BEGIN FS = " " ;
NR == 1 printf "%26s %16s %8s %11sn", $1, $2, $3, $4
NR > 1 printf "%-15s %s(%0.2g) %s %s %sn", $1, $2, $6, $3, $4, $5
$ awk -f 1.awk infile
Accuracy Precision Recall F-measure
bemkl_J_DIFP 0.6001(0.016) 0.01545 0.4304 0.02984
bemkl_J_DI 0.6011(0.014) 0.01390 0.3870 0.02684
bemkl_J_FP 0.4831(0.016) 0.01424 0.3609 0.02740





share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f397147%2fformat-the-number-of-decimal-points%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    $ cat 1.awk
    BEGIN FS = " " ;
    NR == 1 printf "%26s %16s %8s %11sn", $1, $2, $3, $4
    NR > 1 printf "%-15s %s(%0.2g) %s %s %sn", $1, $2, $6, $3, $4, $5
    $ awk -f 1.awk infile
    Accuracy Precision Recall F-measure
    bemkl_J_DIFP 0.6001(0.016) 0.01545 0.4304 0.02984
    bemkl_J_DI 0.6011(0.014) 0.01390 0.3870 0.02684
    bemkl_J_FP 0.4831(0.016) 0.01424 0.3609 0.02740





    share|improve this answer
























      up vote
      1
      down vote



      accepted










      $ cat 1.awk
      BEGIN FS = " " ;
      NR == 1 printf "%26s %16s %8s %11sn", $1, $2, $3, $4
      NR > 1 printf "%-15s %s(%0.2g) %s %s %sn", $1, $2, $6, $3, $4, $5
      $ awk -f 1.awk infile
      Accuracy Precision Recall F-measure
      bemkl_J_DIFP 0.6001(0.016) 0.01545 0.4304 0.02984
      bemkl_J_DI 0.6011(0.014) 0.01390 0.3870 0.02684
      bemkl_J_FP 0.4831(0.016) 0.01424 0.3609 0.02740





      share|improve this answer






















        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        $ cat 1.awk
        BEGIN FS = " " ;
        NR == 1 printf "%26s %16s %8s %11sn", $1, $2, $3, $4
        NR > 1 printf "%-15s %s(%0.2g) %s %s %sn", $1, $2, $6, $3, $4, $5
        $ awk -f 1.awk infile
        Accuracy Precision Recall F-measure
        bemkl_J_DIFP 0.6001(0.016) 0.01545 0.4304 0.02984
        bemkl_J_DI 0.6011(0.014) 0.01390 0.3870 0.02684
        bemkl_J_FP 0.4831(0.016) 0.01424 0.3609 0.02740





        share|improve this answer












        $ cat 1.awk
        BEGIN FS = " " ;
        NR == 1 printf "%26s %16s %8s %11sn", $1, $2, $3, $4
        NR > 1 printf "%-15s %s(%0.2g) %s %s %sn", $1, $2, $6, $3, $4, $5
        $ awk -f 1.awk infile
        Accuracy Precision Recall F-measure
        bemkl_J_DIFP 0.6001(0.016) 0.01545 0.4304 0.02984
        bemkl_J_DI 0.6011(0.014) 0.01390 0.3870 0.02684
        bemkl_J_FP 0.4831(0.016) 0.01424 0.3609 0.02740






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 10 '17 at 3:35









        fpmurphy1

        2,231915




        2,231915



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f397147%2fformat-the-number-of-decimal-points%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?