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.
- {} means
selected files. - ; means trminate the argument.
- ; 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
add a comment |
up vote
0
down vote
favorite
For the command structure -exec command {} ;,i got info in man find.
- {} means
selected files. - ; means trminate the argument.
- ; 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
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
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
For the command structure -exec command {} ;,i got info in man find.
- {} means
selected files. - ; means trminate the argument.
- ; 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
For the command structure -exec command {} ;,i got info in man find.
- {} means
selected files. - ; means trminate the argument.
- ; 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
linux command-line bash find exec
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
add a comment |
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
add a comment |
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:
- It's about
find, not aboutbash. - The tool supports two slightly different
-execactions. - To tell them apart we use two different arguments that terminate
-execstatement; it's a design choice. - These two different arguments are
;and+; it's a design choice. - 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 as3+5=8orconcatenate, to join two strings into one such ass1+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-execinfindcontext.
add a comment |
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:
- It's about
find, not aboutbash. - The tool supports two slightly different
-execactions. - To tell them apart we use two different arguments that terminate
-execstatement; it's a design choice. - These two different arguments are
;and+; it's a design choice. - 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 as3+5=8orconcatenate, to join two strings into one such ass1+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-execinfindcontext.
add a comment |
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:
- It's about
find, not aboutbash. - The tool supports two slightly different
-execactions. - To tell them apart we use two different arguments that terminate
-execstatement; it's a design choice. - These two different arguments are
;and+; it's a design choice. - 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 as3+5=8orconcatenate, to join two strings into one such ass1+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-execinfindcontext.
add a comment |
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:
- It's about
find, not aboutbash. - The tool supports two slightly different
-execactions. - To tell them apart we use two different arguments that terminate
-execstatement; it's a design choice. - These two different arguments are
;and+; it's a design choice. - 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 as3+5=8orconcatenate, to join two strings into one such ass1+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-execinfindcontext.
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:
- It's about
find, not aboutbash. - The tool supports two slightly different
-execactions. - To tell them apart we use two different arguments that terminate
-execstatement; it's a design choice. - These two different arguments are
;and+; it's a design choice. - 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 as3+5=8orconcatenate, to join two strings into one such ass1+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-execinfindcontext.
edited Nov 16 at 4:22
answered Nov 16 at 4:12
Kamil Maciorowski
22.6k155072
22.6k155072
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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