$ cmp -s file1 file2, this command doesn't return anything for the following cases: case 1: both files are different; case 2: both files are same [closed]

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











up vote
-1
down vote

favorite












$ cmp -s file1 file2



The above command doesn't return anything for the following cases:



  • Case 1: both files (file1 and file2) are different;

  • Case 2: both files (file1 and file2) are same.

I tried all the above cases, but my unix system is insensitive.










share|improve this question















closed as off-topic by DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM Aug 11 at 9:31


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM
If this question can be reworded to fit the rules in the help center, please edit the question.
















    up vote
    -1
    down vote

    favorite












    $ cmp -s file1 file2



    The above command doesn't return anything for the following cases:



    • Case 1: both files (file1 and file2) are different;

    • Case 2: both files (file1 and file2) are same.

    I tried all the above cases, but my unix system is insensitive.










    share|improve this question















    closed as off-topic by DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM Aug 11 at 9:31


    This question appears to be off-topic. The users who voted to close gave this specific reason:


    • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM
    If this question can be reworded to fit the rules in the help center, please edit the question.














      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      $ cmp -s file1 file2



      The above command doesn't return anything for the following cases:



      • Case 1: both files (file1 and file2) are different;

      • Case 2: both files (file1 and file2) are same.

      I tried all the above cases, but my unix system is insensitive.










      share|improve this question















      $ cmp -s file1 file2



      The above command doesn't return anything for the following cases:



      • Case 1: both files (file1 and file2) are different;

      • Case 2: both files (file1 and file2) are same.

      I tried all the above cases, but my unix system is insensitive.







      files file-comparison






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 10 at 17:30









      Stéphane Chazelas

      284k53524862




      284k53524862










      asked Aug 10 at 17:18









      Gopinath Pushpa Thirunavukaras

      164




      164




      closed as off-topic by DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM Aug 11 at 9:31


      This question appears to be off-topic. The users who voted to close gave this specific reason:


      • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM
      If this question can be reworded to fit the rules in the help center, please edit the question.




      closed as off-topic by DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM Aug 11 at 9:31


      This question appears to be off-topic. The users who voted to close gave this specific reason:


      • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM
      If this question can be reworded to fit the rules in the help center, please edit the question.




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote













          -s is for silent, it's to tell cmp not to output anything¹ but only to reflect whether the files are identical or not in its exit status so that it can be used for instance in an if shell statement:



          if cmp -s file1 file2; then
          echo same
          else
          echo differ or error
          fi


          Or:



          cmp -s file1 file2 && rm file2


          If you want it to output something, remove the -s. Then cmp will output a message when the files differ stating where they start to differ.




          ¹ except with some implementations for error messages when files can't be opened, not when they differ.






          share|improve this answer






















          • I got understood. I am new to Unix, I never went to shell programming learning till now. Thanks.
            – Gopinath Pushpa Thirunavukaras
            Aug 10 at 17:35

















          up vote
          1
          down vote













          I would question your case 1. If cmp doesn't return anything then the files likely are identical. Try diff file1 file and sum file1 file2 to confirm. Is it possible that the differences are in non-printable characters?






          share|improve this answer



























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            4
            down vote













            -s is for silent, it's to tell cmp not to output anything¹ but only to reflect whether the files are identical or not in its exit status so that it can be used for instance in an if shell statement:



            if cmp -s file1 file2; then
            echo same
            else
            echo differ or error
            fi


            Or:



            cmp -s file1 file2 && rm file2


            If you want it to output something, remove the -s. Then cmp will output a message when the files differ stating where they start to differ.




            ¹ except with some implementations for error messages when files can't be opened, not when they differ.






            share|improve this answer






















            • I got understood. I am new to Unix, I never went to shell programming learning till now. Thanks.
              – Gopinath Pushpa Thirunavukaras
              Aug 10 at 17:35














            up vote
            4
            down vote













            -s is for silent, it's to tell cmp not to output anything¹ but only to reflect whether the files are identical or not in its exit status so that it can be used for instance in an if shell statement:



            if cmp -s file1 file2; then
            echo same
            else
            echo differ or error
            fi


            Or:



            cmp -s file1 file2 && rm file2


            If you want it to output something, remove the -s. Then cmp will output a message when the files differ stating where they start to differ.




            ¹ except with some implementations for error messages when files can't be opened, not when they differ.






            share|improve this answer






















            • I got understood. I am new to Unix, I never went to shell programming learning till now. Thanks.
              – Gopinath Pushpa Thirunavukaras
              Aug 10 at 17:35












            up vote
            4
            down vote










            up vote
            4
            down vote









            -s is for silent, it's to tell cmp not to output anything¹ but only to reflect whether the files are identical or not in its exit status so that it can be used for instance in an if shell statement:



            if cmp -s file1 file2; then
            echo same
            else
            echo differ or error
            fi


            Or:



            cmp -s file1 file2 && rm file2


            If you want it to output something, remove the -s. Then cmp will output a message when the files differ stating where they start to differ.




            ¹ except with some implementations for error messages when files can't be opened, not when they differ.






            share|improve this answer














            -s is for silent, it's to tell cmp not to output anything¹ but only to reflect whether the files are identical or not in its exit status so that it can be used for instance in an if shell statement:



            if cmp -s file1 file2; then
            echo same
            else
            echo differ or error
            fi


            Or:



            cmp -s file1 file2 && rm file2


            If you want it to output something, remove the -s. Then cmp will output a message when the files differ stating where they start to differ.




            ¹ except with some implementations for error messages when files can't be opened, not when they differ.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 10 at 17:33

























            answered Aug 10 at 17:28









            Stéphane Chazelas

            284k53524862




            284k53524862











            • I got understood. I am new to Unix, I never went to shell programming learning till now. Thanks.
              – Gopinath Pushpa Thirunavukaras
              Aug 10 at 17:35
















            • I got understood. I am new to Unix, I never went to shell programming learning till now. Thanks.
              – Gopinath Pushpa Thirunavukaras
              Aug 10 at 17:35















            I got understood. I am new to Unix, I never went to shell programming learning till now. Thanks.
            – Gopinath Pushpa Thirunavukaras
            Aug 10 at 17:35




            I got understood. I am new to Unix, I never went to shell programming learning till now. Thanks.
            – Gopinath Pushpa Thirunavukaras
            Aug 10 at 17:35












            up vote
            1
            down vote













            I would question your case 1. If cmp doesn't return anything then the files likely are identical. Try diff file1 file and sum file1 file2 to confirm. Is it possible that the differences are in non-printable characters?






            share|improve this answer
























              up vote
              1
              down vote













              I would question your case 1. If cmp doesn't return anything then the files likely are identical. Try diff file1 file and sum file1 file2 to confirm. Is it possible that the differences are in non-printable characters?






              share|improve this answer






















                up vote
                1
                down vote










                up vote
                1
                down vote









                I would question your case 1. If cmp doesn't return anything then the files likely are identical. Try diff file1 file and sum file1 file2 to confirm. Is it possible that the differences are in non-printable characters?






                share|improve this answer












                I would question your case 1. If cmp doesn't return anything then the files likely are identical. Try diff file1 file and sum file1 file2 to confirm. Is it possible that the differences are in non-printable characters?







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 10 at 17:29









                Doug O'Neal

                2,6271716




                2,6271716












                    Popular posts from this blog

                    Peggy Mitchell

                    Palaiologos

                    The Forum (Inglewood, California)