Why did this command put a whitespace at the beginning?

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











up vote
1
down vote

favorite












I have this code in a shell script:



sort input | uniq -c | sort -nr > output


The input file had no preceding white spaces, but the output does. How do I fix this? This is in bash










share|improve this question









New contributor




Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    1
    down vote

    favorite












    I have this code in a shell script:



    sort input | uniq -c | sort -nr > output


    The input file had no preceding white spaces, but the output does. How do I fix this? This is in bash










    share|improve this question









    New contributor




    Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have this code in a shell script:



      sort input | uniq -c | sort -nr > output


      The input file had no preceding white spaces, but the output does. How do I fix this? This is in bash










      share|improve this question









      New contributor




      Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I have this code in a shell script:



      sort input | uniq -c | sort -nr > output


      The input file had no preceding white spaces, but the output does. How do I fix this? This is in bash







      command-line bash uniq






      share|improve this question









      New contributor




      Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 11 mins ago









      wjandrea

      7,45142257




      7,45142257






      New contributor




      Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 52 mins ago









      Jeremy Wik

      61




      61




      New contributor




      Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote














          The default behaviour of uniq is to right-justify the frequency in a
          line 7 spaces wide, then separate the frequency from the item with a
          single space.




          Source : https://www.thelinuxrain.com/articles/tweaking-uniq-c



          Remove the leading spaces with sed :



          $ sort input | uniq -c | sort -nr | sed 's/^s*//' > output





          share|improve this answer





























            up vote
            1
            down vote













            uniq -c adds leading whitespace. E.g.



            $ echo test
            test
            $ echo test | uniq -c
            1 test


            You could add a command at the end of the pipeline to remove it. E.g.



            $ echo test | uniq -c | sed 's/^s*//'
            1 test





            share|improve this answer




















              Your Answer







              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "89"
              ;
              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: true,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );






              Jeremy Wik is a new contributor. Be nice, and check out our Code of Conduct.









               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1087885%2fwhy-did-this-command-put-a-whitespace-at-the-beginning%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              2
              down vote














              The default behaviour of uniq is to right-justify the frequency in a
              line 7 spaces wide, then separate the frequency from the item with a
              single space.




              Source : https://www.thelinuxrain.com/articles/tweaking-uniq-c



              Remove the leading spaces with sed :



              $ sort input | uniq -c | sort -nr | sed 's/^s*//' > output





              share|improve this answer


























                up vote
                2
                down vote














                The default behaviour of uniq is to right-justify the frequency in a
                line 7 spaces wide, then separate the frequency from the item with a
                single space.




                Source : https://www.thelinuxrain.com/articles/tweaking-uniq-c



                Remove the leading spaces with sed :



                $ sort input | uniq -c | sort -nr | sed 's/^s*//' > output





                share|improve this answer
























                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote










                  The default behaviour of uniq is to right-justify the frequency in a
                  line 7 spaces wide, then separate the frequency from the item with a
                  single space.




                  Source : https://www.thelinuxrain.com/articles/tweaking-uniq-c



                  Remove the leading spaces with sed :



                  $ sort input | uniq -c | sort -nr | sed 's/^s*//' > output





                  share|improve this answer















                  The default behaviour of uniq is to right-justify the frequency in a
                  line 7 spaces wide, then separate the frequency from the item with a
                  single space.




                  Source : https://www.thelinuxrain.com/articles/tweaking-uniq-c



                  Remove the leading spaces with sed :



                  $ sort input | uniq -c | sort -nr | sed 's/^s*//' > output






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 20 mins ago









                  wjandrea

                  7,45142257




                  7,45142257










                  answered 25 mins ago









                  Gounou

                  935




                  935






















                      up vote
                      1
                      down vote













                      uniq -c adds leading whitespace. E.g.



                      $ echo test
                      test
                      $ echo test | uniq -c
                      1 test


                      You could add a command at the end of the pipeline to remove it. E.g.



                      $ echo test | uniq -c | sed 's/^s*//'
                      1 test





                      share|improve this answer
























                        up vote
                        1
                        down vote













                        uniq -c adds leading whitespace. E.g.



                        $ echo test
                        test
                        $ echo test | uniq -c
                        1 test


                        You could add a command at the end of the pipeline to remove it. E.g.



                        $ echo test | uniq -c | sed 's/^s*//'
                        1 test





                        share|improve this answer






















                          up vote
                          1
                          down vote










                          up vote
                          1
                          down vote









                          uniq -c adds leading whitespace. E.g.



                          $ echo test
                          test
                          $ echo test | uniq -c
                          1 test


                          You could add a command at the end of the pipeline to remove it. E.g.



                          $ echo test | uniq -c | sed 's/^s*//'
                          1 test





                          share|improve this answer












                          uniq -c adds leading whitespace. E.g.



                          $ echo test
                          test
                          $ echo test | uniq -c
                          1 test


                          You could add a command at the end of the pipeline to remove it. E.g.



                          $ echo test | uniq -c | sed 's/^s*//'
                          1 test






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 25 mins ago









                          wjandrea

                          7,45142257




                          7,45142257




















                              Jeremy Wik is a new contributor. Be nice, and check out our Code of Conduct.









                               

                              draft saved


                              draft discarded


















                              Jeremy Wik is a new contributor. Be nice, and check out our Code of Conduct.












                              Jeremy Wik is a new contributor. Be nice, and check out our Code of Conduct.











                              Jeremy Wik is a new contributor. Be nice, and check out our Code of Conduct.













                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1087885%2fwhy-did-this-command-put-a-whitespace-at-the-beginning%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?