What does + mean in the bash `-exec command {} +`?











up vote
0
down vote

favorite












For the command structure -exec command {} ;,i got info in man find.




  1. {} means selected files.

  2. ; means trminate the argument.

  3. ; escaped to protect them from expansion by the shell.


In the paragraph related to -exec command {} +.



 -exec command {} +
This variant of the -exec action runs the specified command on
the selected files, but the command line is built by appending
each selected file name at the end; the total number of invoca‐
tions of the command will be much less than the number of
matched files. The command line is built in much the same way
that xargs builds its command lines. Only one instance of `{}'
is allowed within the command, and (when find is being invoked
from a shell) it should be quoted (for example, '{}') to protect
it from interpretation by shells. The command is executed in
the starting directory. If any invocation returns a non-zero
value as exit status, then find returns a non-zero exit status.
If find encounters an error, this can sometimes cause an immedi‐
ate exit, so some pending commands may not be run at all. This
variant of -exec always returns true.


It never say something on + ,What does + mean in the bash -exec command {} +?

It means to terminate the argument such as ;?
+ means plus such as 3+5=8 or concatenate , to join two strings into one such as s1+s2.

It is a strange thing to assign a meaning terminate the argument for +.










share|improve this question
























  • This was quite well explained over at SO Prime here, stackoverflow.com/questions/6085156/… And at Unix SE here, unix.stackexchange.com/questions/195939/…
    – Uberfuzzy
    Nov 16 at 4:08















up vote
0
down vote

favorite












For the command structure -exec command {} ;,i got info in man find.




  1. {} means selected files.

  2. ; means trminate the argument.

  3. ; escaped to protect them from expansion by the shell.


In the paragraph related to -exec command {} +.



 -exec command {} +
This variant of the -exec action runs the specified command on
the selected files, but the command line is built by appending
each selected file name at the end; the total number of invoca‐
tions of the command will be much less than the number of
matched files. The command line is built in much the same way
that xargs builds its command lines. Only one instance of `{}'
is allowed within the command, and (when find is being invoked
from a shell) it should be quoted (for example, '{}') to protect
it from interpretation by shells. The command is executed in
the starting directory. If any invocation returns a non-zero
value as exit status, then find returns a non-zero exit status.
If find encounters an error, this can sometimes cause an immedi‐
ate exit, so some pending commands may not be run at all. This
variant of -exec always returns true.


It never say something on + ,What does + mean in the bash -exec command {} +?

It means to terminate the argument such as ;?
+ means plus such as 3+5=8 or concatenate , to join two strings into one such as s1+s2.

It is a strange thing to assign a meaning terminate the argument for +.










share|improve this question
























  • This was quite well explained over at SO Prime here, stackoverflow.com/questions/6085156/… And at Unix SE here, unix.stackexchange.com/questions/195939/…
    – Uberfuzzy
    Nov 16 at 4:08













up vote
0
down vote

favorite









up vote
0
down vote

favorite











For the command structure -exec command {} ;,i got info in man find.




  1. {} means selected files.

  2. ; means trminate the argument.

  3. ; escaped to protect them from expansion by the shell.


In the paragraph related to -exec command {} +.



 -exec command {} +
This variant of the -exec action runs the specified command on
the selected files, but the command line is built by appending
each selected file name at the end; the total number of invoca‐
tions of the command will be much less than the number of
matched files. The command line is built in much the same way
that xargs builds its command lines. Only one instance of `{}'
is allowed within the command, and (when find is being invoked
from a shell) it should be quoted (for example, '{}') to protect
it from interpretation by shells. The command is executed in
the starting directory. If any invocation returns a non-zero
value as exit status, then find returns a non-zero exit status.
If find encounters an error, this can sometimes cause an immedi‐
ate exit, so some pending commands may not be run at all. This
variant of -exec always returns true.


It never say something on + ,What does + mean in the bash -exec command {} +?

It means to terminate the argument such as ;?
+ means plus such as 3+5=8 or concatenate , to join two strings into one such as s1+s2.

It is a strange thing to assign a meaning terminate the argument for +.










share|improve this question















For the command structure -exec command {} ;,i got info in man find.




  1. {} means selected files.

  2. ; means trminate the argument.

  3. ; escaped to protect them from expansion by the shell.


In the paragraph related to -exec command {} +.



 -exec command {} +
This variant of the -exec action runs the specified command on
the selected files, but the command line is built by appending
each selected file name at the end; the total number of invoca‐
tions of the command will be much less than the number of
matched files. The command line is built in much the same way
that xargs builds its command lines. Only one instance of `{}'
is allowed within the command, and (when find is being invoked
from a shell) it should be quoted (for example, '{}') to protect
it from interpretation by shells. The command is executed in
the starting directory. If any invocation returns a non-zero
value as exit status, then find returns a non-zero exit status.
If find encounters an error, this can sometimes cause an immedi‐
ate exit, so some pending commands may not be run at all. This
variant of -exec always returns true.


It never say something on + ,What does + mean in the bash -exec command {} +?

It means to terminate the argument such as ;?
+ means plus such as 3+5=8 or concatenate , to join two strings into one such as s1+s2.

It is a strange thing to assign a meaning terminate the argument for +.







linux command-line bash find exec






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 at 2:47

























asked Nov 16 at 2:40









scrapy

1765




1765












  • This was quite well explained over at SO Prime here, stackoverflow.com/questions/6085156/… And at Unix SE here, unix.stackexchange.com/questions/195939/…
    – Uberfuzzy
    Nov 16 at 4:08


















  • This was quite well explained over at SO Prime here, stackoverflow.com/questions/6085156/… And at Unix SE here, unix.stackexchange.com/questions/195939/…
    – Uberfuzzy
    Nov 16 at 4:08
















This was quite well explained over at SO Prime here, stackoverflow.com/questions/6085156/… And at Unix SE here, unix.stackexchange.com/questions/195939/…
– Uberfuzzy
Nov 16 at 4:08




This was quite well explained over at SO Prime here, stackoverflow.com/questions/6085156/… And at Unix SE here, unix.stackexchange.com/questions/195939/…
– Uberfuzzy
Nov 16 at 4:08










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










It has nothing to do with Bash, it's a part of find syntax. The command has to know where the -exec action ends. It ends at ; or at +. Depending on the terminating character, a proper variant of -exec action is used.



Why were these two characters chosen for this purpose? I don't know. Some way to end -exec statement was a must and somebody chose ; and +. Now the characters are parts of POSIX standard when it comes to the find command.



We can only guess that ; was chosen because it can also terminate a command in a shell, so the purpose is similar. For this reason, however, ; that needs to be seen by find has to be treated specially in the shell, hence ; (';' or ";" also works). There's no such problem with +.



Technically almost any other string could have been chosen instead of + (the same with ;). Note that -exec, {}, + and ; (after it passes the shell thanks to escaping or quoting), possible tests or actions like -type or -print – they all are arguments to find; they become meaningful when find processes them, their meaning comes from how find was invented.



To summarize:




  1. It's about find, not about bash.

  2. The tool supports two slightly different -exec actions.

  3. To tell them apart we use two different arguments that terminate -exec statement; it's a design choice.

  4. These two different arguments are ; and +; it's a design choice.

  5. These choices could have been made differently. Even if there is a story behind + (which I don't know), it's trivia, not something really meaningful. I can only speculate {} + is for "one argument or more" like 10+ sometimes means "ten or more".




Broader insight




+ means plus such as 3+5=8 or concatenate, to join two strings into one such as s1+s2. It is a strange thing to assign a meaning terminate the argument for +.




How about




> means "greater than"… It is a strange thing to assign a meaning "redirect" for >.




"+ means plus" is not from God. Somebody decided, others followed and the symbol stuck.




  • Somebody decided + means "plus" in mathematics.

  • Somebody decided > means "greater than" in mathematics.

  • Somebody decided > redirects in a shell.

  • Somebody decided + terminates -exec in find context.






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    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: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1375868%2fwhat-does-mean-in-the-bash-exec-command%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    It has nothing to do with Bash, it's a part of find syntax. The command has to know where the -exec action ends. It ends at ; or at +. Depending on the terminating character, a proper variant of -exec action is used.



    Why were these two characters chosen for this purpose? I don't know. Some way to end -exec statement was a must and somebody chose ; and +. Now the characters are parts of POSIX standard when it comes to the find command.



    We can only guess that ; was chosen because it can also terminate a command in a shell, so the purpose is similar. For this reason, however, ; that needs to be seen by find has to be treated specially in the shell, hence ; (';' or ";" also works). There's no such problem with +.



    Technically almost any other string could have been chosen instead of + (the same with ;). Note that -exec, {}, + and ; (after it passes the shell thanks to escaping or quoting), possible tests or actions like -type or -print – they all are arguments to find; they become meaningful when find processes them, their meaning comes from how find was invented.



    To summarize:




    1. It's about find, not about bash.

    2. The tool supports two slightly different -exec actions.

    3. To tell them apart we use two different arguments that terminate -exec statement; it's a design choice.

    4. These two different arguments are ; and +; it's a design choice.

    5. These choices could have been made differently. Even if there is a story behind + (which I don't know), it's trivia, not something really meaningful. I can only speculate {} + is for "one argument or more" like 10+ sometimes means "ten or more".




    Broader insight




    + means plus such as 3+5=8 or concatenate, to join two strings into one such as s1+s2. It is a strange thing to assign a meaning terminate the argument for +.




    How about




    > means "greater than"… It is a strange thing to assign a meaning "redirect" for >.




    "+ means plus" is not from God. Somebody decided, others followed and the symbol stuck.




    • Somebody decided + means "plus" in mathematics.

    • Somebody decided > means "greater than" in mathematics.

    • Somebody decided > redirects in a shell.

    • Somebody decided + terminates -exec in find context.






    share|improve this answer



























      up vote
      1
      down vote



      accepted










      It has nothing to do with Bash, it's a part of find syntax. The command has to know where the -exec action ends. It ends at ; or at +. Depending on the terminating character, a proper variant of -exec action is used.



      Why were these two characters chosen for this purpose? I don't know. Some way to end -exec statement was a must and somebody chose ; and +. Now the characters are parts of POSIX standard when it comes to the find command.



      We can only guess that ; was chosen because it can also terminate a command in a shell, so the purpose is similar. For this reason, however, ; that needs to be seen by find has to be treated specially in the shell, hence ; (';' or ";" also works). There's no such problem with +.



      Technically almost any other string could have been chosen instead of + (the same with ;). Note that -exec, {}, + and ; (after it passes the shell thanks to escaping or quoting), possible tests or actions like -type or -print – they all are arguments to find; they become meaningful when find processes them, their meaning comes from how find was invented.



      To summarize:




      1. It's about find, not about bash.

      2. The tool supports two slightly different -exec actions.

      3. To tell them apart we use two different arguments that terminate -exec statement; it's a design choice.

      4. These two different arguments are ; and +; it's a design choice.

      5. These choices could have been made differently. Even if there is a story behind + (which I don't know), it's trivia, not something really meaningful. I can only speculate {} + is for "one argument or more" like 10+ sometimes means "ten or more".




      Broader insight




      + means plus such as 3+5=8 or concatenate, to join two strings into one such as s1+s2. It is a strange thing to assign a meaning terminate the argument for +.




      How about




      > means "greater than"… It is a strange thing to assign a meaning "redirect" for >.




      "+ means plus" is not from God. Somebody decided, others followed and the symbol stuck.




      • Somebody decided + means "plus" in mathematics.

      • Somebody decided > means "greater than" in mathematics.

      • Somebody decided > redirects in a shell.

      • Somebody decided + terminates -exec in find context.






      share|improve this answer

























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        It has nothing to do with Bash, it's a part of find syntax. The command has to know where the -exec action ends. It ends at ; or at +. Depending on the terminating character, a proper variant of -exec action is used.



        Why were these two characters chosen for this purpose? I don't know. Some way to end -exec statement was a must and somebody chose ; and +. Now the characters are parts of POSIX standard when it comes to the find command.



        We can only guess that ; was chosen because it can also terminate a command in a shell, so the purpose is similar. For this reason, however, ; that needs to be seen by find has to be treated specially in the shell, hence ; (';' or ";" also works). There's no such problem with +.



        Technically almost any other string could have been chosen instead of + (the same with ;). Note that -exec, {}, + and ; (after it passes the shell thanks to escaping or quoting), possible tests or actions like -type or -print – they all are arguments to find; they become meaningful when find processes them, their meaning comes from how find was invented.



        To summarize:




        1. It's about find, not about bash.

        2. The tool supports two slightly different -exec actions.

        3. To tell them apart we use two different arguments that terminate -exec statement; it's a design choice.

        4. These two different arguments are ; and +; it's a design choice.

        5. These choices could have been made differently. Even if there is a story behind + (which I don't know), it's trivia, not something really meaningful. I can only speculate {} + is for "one argument or more" like 10+ sometimes means "ten or more".




        Broader insight




        + means plus such as 3+5=8 or concatenate, to join two strings into one such as s1+s2. It is a strange thing to assign a meaning terminate the argument for +.




        How about




        > means "greater than"… It is a strange thing to assign a meaning "redirect" for >.




        "+ means plus" is not from God. Somebody decided, others followed and the symbol stuck.




        • Somebody decided + means "plus" in mathematics.

        • Somebody decided > means "greater than" in mathematics.

        • Somebody decided > redirects in a shell.

        • Somebody decided + terminates -exec in find context.






        share|improve this answer














        It has nothing to do with Bash, it's a part of find syntax. The command has to know where the -exec action ends. It ends at ; or at +. Depending on the terminating character, a proper variant of -exec action is used.



        Why were these two characters chosen for this purpose? I don't know. Some way to end -exec statement was a must and somebody chose ; and +. Now the characters are parts of POSIX standard when it comes to the find command.



        We can only guess that ; was chosen because it can also terminate a command in a shell, so the purpose is similar. For this reason, however, ; that needs to be seen by find has to be treated specially in the shell, hence ; (';' or ";" also works). There's no such problem with +.



        Technically almost any other string could have been chosen instead of + (the same with ;). Note that -exec, {}, + and ; (after it passes the shell thanks to escaping or quoting), possible tests or actions like -type or -print – they all are arguments to find; they become meaningful when find processes them, their meaning comes from how find was invented.



        To summarize:




        1. It's about find, not about bash.

        2. The tool supports two slightly different -exec actions.

        3. To tell them apart we use two different arguments that terminate -exec statement; it's a design choice.

        4. These two different arguments are ; and +; it's a design choice.

        5. These choices could have been made differently. Even if there is a story behind + (which I don't know), it's trivia, not something really meaningful. I can only speculate {} + is for "one argument or more" like 10+ sometimes means "ten or more".




        Broader insight




        + means plus such as 3+5=8 or concatenate, to join two strings into one such as s1+s2. It is a strange thing to assign a meaning terminate the argument for +.




        How about




        > means "greater than"… It is a strange thing to assign a meaning "redirect" for >.




        "+ means plus" is not from God. Somebody decided, others followed and the symbol stuck.




        • Somebody decided + means "plus" in mathematics.

        • Somebody decided > means "greater than" in mathematics.

        • Somebody decided > redirects in a shell.

        • Somebody decided + terminates -exec in find context.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 16 at 4:22

























        answered Nov 16 at 4:12









        Kamil Maciorowski

        22.6k155072




        22.6k155072






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1375868%2fwhat-does-mean-in-the-bash-exec-command%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Plaza Victoria

            Brian Clough

            Cáceres