I want to know exact command of “find . -name '*.c' -or -name '*.cpp'” in Linux

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











up vote
-4
down vote

favorite












I'm studying shell in Linux these days. and I've had one question.



Please, look at below command:



$ find . -name '*.c' -or -name '*.cpp'


Above command is processed like below command internally?



$ find . -name '*.c' -and -print -or -name '*.cpp' -and -print









share|improve this question





















  • Read find(1) perhaps by typing man find and read the man page of every command before using it. Some few commands are builtin, e.g. cd. So read also the documentation of your shell, e.g. bash(1)
    – Basile Starynkevitch
    Sep 25 '17 at 7:05















up vote
-4
down vote

favorite












I'm studying shell in Linux these days. and I've had one question.



Please, look at below command:



$ find . -name '*.c' -or -name '*.cpp'


Above command is processed like below command internally?



$ find . -name '*.c' -and -print -or -name '*.cpp' -and -print









share|improve this question





















  • Read find(1) perhaps by typing man find and read the man page of every command before using it. Some few commands are builtin, e.g. cd. So read also the documentation of your shell, e.g. bash(1)
    – Basile Starynkevitch
    Sep 25 '17 at 7:05













up vote
-4
down vote

favorite









up vote
-4
down vote

favorite











I'm studying shell in Linux these days. and I've had one question.



Please, look at below command:



$ find . -name '*.c' -or -name '*.cpp'


Above command is processed like below command internally?



$ find . -name '*.c' -and -print -or -name '*.cpp' -and -print









share|improve this question













I'm studying shell in Linux these days. and I've had one question.



Please, look at below command:



$ find . -name '*.c' -or -name '*.cpp'


Above command is processed like below command internally?



$ find . -name '*.c' -and -print -or -name '*.cpp' -and -print






linux find command






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 25 '17 at 3:36









user2063889

11




11











  • Read find(1) perhaps by typing man find and read the man page of every command before using it. Some few commands are builtin, e.g. cd. So read also the documentation of your shell, e.g. bash(1)
    – Basile Starynkevitch
    Sep 25 '17 at 7:05

















  • Read find(1) perhaps by typing man find and read the man page of every command before using it. Some few commands are builtin, e.g. cd. So read also the documentation of your shell, e.g. bash(1)
    – Basile Starynkevitch
    Sep 25 '17 at 7:05
















Read find(1) perhaps by typing man find and read the man page of every command before using it. Some few commands are builtin, e.g. cd. So read also the documentation of your shell, e.g. bash(1)
– Basile Starynkevitch
Sep 25 '17 at 7:05





Read find(1) perhaps by typing man find and read the man page of every command before using it. Some few commands are builtin, e.g. cd. So read also the documentation of your shell, e.g. bash(1)
– Basile Starynkevitch
Sep 25 '17 at 7:05











3 Answers
3






active

oldest

votes

















up vote
3
down vote



accepted










man find says:



 If the whole expression contains no actions other than -prune or -print,
-print is performed on all files for which the whole expression is true.


So yes, it's equivalent, but it's probably easier to think of it as:



find . ( -name '*.c' -or -name '*.cpp' ) -and -print


or simpler, and POSIX-compliant:



find . ( -name '*.c' -o -name '*.cpp' ) -print





share|improve this answer





























    up vote
    0
    down vote













    Basically both commands means same and display same output. Why to do with longer when you have shorter way?






    share|improve this answer




















    • @roaima this look like a comment to me, and I flag as such.
      – Archemar
      Sep 25 '17 at 7:16

















    up vote
    0
    down vote













    The OR and AND operators follow Boolean logic.



    For primitives A = -name '*.c', B = -name '*.cpp', C = -print we have the following equations



    Your first example: (A+B).C



    Your second example: (A.C)+(B.C)



    These have a straightforward mathematical equivalence, ie they are the same. But the first is shorter and more succinct.






    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%2f394232%2fi-want-to-know-exact-command-of-find-name-c-or-name-cpp-in-linux%23new-answer', 'question_page');

      );

      Post as a guest






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      3
      down vote



      accepted










      man find says:



       If the whole expression contains no actions other than -prune or -print,
      -print is performed on all files for which the whole expression is true.


      So yes, it's equivalent, but it's probably easier to think of it as:



      find . ( -name '*.c' -or -name '*.cpp' ) -and -print


      or simpler, and POSIX-compliant:



      find . ( -name '*.c' -o -name '*.cpp' ) -print





      share|improve this answer


























        up vote
        3
        down vote



        accepted










        man find says:



         If the whole expression contains no actions other than -prune or -print,
        -print is performed on all files for which the whole expression is true.


        So yes, it's equivalent, but it's probably easier to think of it as:



        find . ( -name '*.c' -or -name '*.cpp' ) -and -print


        or simpler, and POSIX-compliant:



        find . ( -name '*.c' -o -name '*.cpp' ) -print





        share|improve this answer
























          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          man find says:



           If the whole expression contains no actions other than -prune or -print,
          -print is performed on all files for which the whole expression is true.


          So yes, it's equivalent, but it's probably easier to think of it as:



          find . ( -name '*.c' -or -name '*.cpp' ) -and -print


          or simpler, and POSIX-compliant:



          find . ( -name '*.c' -o -name '*.cpp' ) -print





          share|improve this answer














          man find says:



           If the whole expression contains no actions other than -prune or -print,
          -print is performed on all files for which the whole expression is true.


          So yes, it's equivalent, but it's probably easier to think of it as:



          find . ( -name '*.c' -or -name '*.cpp' ) -and -print


          or simpler, and POSIX-compliant:



          find . ( -name '*.c' -o -name '*.cpp' ) -print






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Sep 25 '17 at 3:54

























          answered Sep 25 '17 at 3:48









          Mikel

          37.8k996121




          37.8k996121






















              up vote
              0
              down vote













              Basically both commands means same and display same output. Why to do with longer when you have shorter way?






              share|improve this answer




















              • @roaima this look like a comment to me, and I flag as such.
                – Archemar
                Sep 25 '17 at 7:16














              up vote
              0
              down vote













              Basically both commands means same and display same output. Why to do with longer when you have shorter way?






              share|improve this answer




















              • @roaima this look like a comment to me, and I flag as such.
                – Archemar
                Sep 25 '17 at 7:16












              up vote
              0
              down vote










              up vote
              0
              down vote









              Basically both commands means same and display same output. Why to do with longer when you have shorter way?






              share|improve this answer












              Basically both commands means same and display same output. Why to do with longer when you have shorter way?







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Sep 25 '17 at 3:46









              BDN

              100112




              100112











              • @roaima this look like a comment to me, and I flag as such.
                – Archemar
                Sep 25 '17 at 7:16
















              • @roaima this look like a comment to me, and I flag as such.
                – Archemar
                Sep 25 '17 at 7:16















              @roaima this look like a comment to me, and I flag as such.
              – Archemar
              Sep 25 '17 at 7:16




              @roaima this look like a comment to me, and I flag as such.
              – Archemar
              Sep 25 '17 at 7:16










              up vote
              0
              down vote













              The OR and AND operators follow Boolean logic.



              For primitives A = -name '*.c', B = -name '*.cpp', C = -print we have the following equations



              Your first example: (A+B).C



              Your second example: (A.C)+(B.C)



              These have a straightforward mathematical equivalence, ie they are the same. But the first is shorter and more succinct.






              share|improve this answer
























                up vote
                0
                down vote













                The OR and AND operators follow Boolean logic.



                For primitives A = -name '*.c', B = -name '*.cpp', C = -print we have the following equations



                Your first example: (A+B).C



                Your second example: (A.C)+(B.C)



                These have a straightforward mathematical equivalence, ie they are the same. But the first is shorter and more succinct.






                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  The OR and AND operators follow Boolean logic.



                  For primitives A = -name '*.c', B = -name '*.cpp', C = -print we have the following equations



                  Your first example: (A+B).C



                  Your second example: (A.C)+(B.C)



                  These have a straightforward mathematical equivalence, ie they are the same. But the first is shorter and more succinct.






                  share|improve this answer












                  The OR and AND operators follow Boolean logic.



                  For primitives A = -name '*.c', B = -name '*.cpp', C = -print we have the following equations



                  Your first example: (A+B).C



                  Your second example: (A.C)+(B.C)



                  These have a straightforward mathematical equivalence, ie they are the same. But the first is shorter and more succinct.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Sep 25 '17 at 6:56









                  roaima

                  40.2k547110




                  40.2k547110



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394232%2fi-want-to-know-exact-command-of-find-name-c-or-name-cpp-in-linux%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?