I want to know exact command of âfind . -name '*.c' -or -name '*.cpp'â in Linux
Clash 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
linux find command
add a comment |Â
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
linux find command
Read find(1) perhaps by typingman 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
add a comment |Â
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
linux find command
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
linux find command
asked Sep 25 '17 at 3:36
user2063889
11
11
Read find(1) perhaps by typingman 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
add a comment |Â
Read find(1) perhaps by typingman 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
add a comment |Â
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
add a comment |Â
up vote
0
down vote
Basically both commands means same and display same output. Why to do with longer when you have shorter way?
@roaima this look like a comment to me, and I flag as such.
â Archemar
Sep 25 '17 at 7:16
add a comment |Â
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.
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
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
edited Sep 25 '17 at 3:54
answered Sep 25 '17 at 3:48
Mikel
37.8k996121
37.8k996121
add a comment |Â
add a comment |Â
up vote
0
down vote
Basically both commands means same and display same output. Why to do with longer when you have shorter way?
@roaima this look like a comment to me, and I flag as such.
â Archemar
Sep 25 '17 at 7:16
add a comment |Â
up vote
0
down vote
Basically both commands means same and display same output. Why to do with longer when you have shorter way?
@roaima this look like a comment to me, and I flag as such.
â Archemar
Sep 25 '17 at 7:16
add a comment |Â
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?
Basically both commands means same and display same output. Why to do with longer when you have shorter way?
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
add a comment |Â
@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
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
answered Sep 25 '17 at 6:56
roaima
40.2k547110
40.2k547110
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
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
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
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
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
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