What does this IF statement mean
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have been trying to find online what these if statement mean. Below are a few.
if [ "$snums[k]" != "NA" -a ! -f "$aliases[k].4dfp.img" ]; then
if [ -f "$dcmfile" -a -n "`cat $dcmfile`" ]; then
The -a
used in these two examples do not make senses to me.
linux bash
add a comment |Â
up vote
1
down vote
favorite
I have been trying to find online what these if statement mean. Below are a few.
if [ "$snums[k]" != "NA" -a ! -f "$aliases[k].4dfp.img" ]; then
if [ -f "$dcmfile" -a -n "`cat $dcmfile`" ]; then
The -a
used in these two examples do not make senses to me.
linux bash
A good reason you may not have seen-a
or-o
is that they have been declared "obsolescent" by POSIX. Script authors are strongly encouraged to use the shell's&&
and||
instead
â Fox
Jul 10 at 23:20
Oh i see. I always thought -a was for checking to see if a file exists.
â Aaron Tanenbaum
Jul 11 at 15:41
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have been trying to find online what these if statement mean. Below are a few.
if [ "$snums[k]" != "NA" -a ! -f "$aliases[k].4dfp.img" ]; then
if [ -f "$dcmfile" -a -n "`cat $dcmfile`" ]; then
The -a
used in these two examples do not make senses to me.
linux bash
I have been trying to find online what these if statement mean. Below are a few.
if [ "$snums[k]" != "NA" -a ! -f "$aliases[k].4dfp.img" ]; then
if [ -f "$dcmfile" -a -n "`cat $dcmfile`" ]; then
The -a
used in these two examples do not make senses to me.
linux bash
edited Jul 10 at 20:32
SivaPrasath
3,68311636
3,68311636
asked Jul 10 at 20:20
Aaron Tanenbaum
61
61
A good reason you may not have seen-a
or-o
is that they have been declared "obsolescent" by POSIX. Script authors are strongly encouraged to use the shell's&&
and||
instead
â Fox
Jul 10 at 23:20
Oh i see. I always thought -a was for checking to see if a file exists.
â Aaron Tanenbaum
Jul 11 at 15:41
add a comment |Â
A good reason you may not have seen-a
or-o
is that they have been declared "obsolescent" by POSIX. Script authors are strongly encouraged to use the shell's&&
and||
instead
â Fox
Jul 10 at 23:20
Oh i see. I always thought -a was for checking to see if a file exists.
â Aaron Tanenbaum
Jul 11 at 15:41
A good reason you may not have seen
-a
or -o
is that they have been declared "obsolescent" by POSIX. Script authors are strongly encouraged to use the shell's &&
and ||
insteadâ Fox
Jul 10 at 23:20
A good reason you may not have seen
-a
or -o
is that they have been declared "obsolescent" by POSIX. Script authors are strongly encouraged to use the shell's &&
and ||
insteadâ Fox
Jul 10 at 23:20
Oh i see. I always thought -a was for checking to see if a file exists.
â Aaron Tanenbaum
Jul 11 at 15:41
Oh i see. I always thought -a was for checking to see if a file exists.
â Aaron Tanenbaum
Jul 11 at 15:41
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
-a
is logical AND. If both the operands are true, then the condition becomes true otherwise false.
-n
Checks if the given string operand size is non-zero; if it is nonzero length, then it returns true.
1
And-f
checks if the following word is a regular file. Also, you can use-s
to check if a file is not empty.
â l0b0
Jul 10 at 21:27
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
-a
is logical AND. If both the operands are true, then the condition becomes true otherwise false.
-n
Checks if the given string operand size is non-zero; if it is nonzero length, then it returns true.
1
And-f
checks if the following word is a regular file. Also, you can use-s
to check if a file is not empty.
â l0b0
Jul 10 at 21:27
add a comment |Â
up vote
2
down vote
-a
is logical AND. If both the operands are true, then the condition becomes true otherwise false.
-n
Checks if the given string operand size is non-zero; if it is nonzero length, then it returns true.
1
And-f
checks if the following word is a regular file. Also, you can use-s
to check if a file is not empty.
â l0b0
Jul 10 at 21:27
add a comment |Â
up vote
2
down vote
up vote
2
down vote
-a
is logical AND. If both the operands are true, then the condition becomes true otherwise false.
-n
Checks if the given string operand size is non-zero; if it is nonzero length, then it returns true.
-a
is logical AND. If both the operands are true, then the condition becomes true otherwise false.
-n
Checks if the given string operand size is non-zero; if it is nonzero length, then it returns true.
answered Jul 10 at 20:34
SivaPrasath
3,68311636
3,68311636
1
And-f
checks if the following word is a regular file. Also, you can use-s
to check if a file is not empty.
â l0b0
Jul 10 at 21:27
add a comment |Â
1
And-f
checks if the following word is a regular file. Also, you can use-s
to check if a file is not empty.
â l0b0
Jul 10 at 21:27
1
1
And
-f
checks if the following word is a regular file. Also, you can use -s
to check if a file is not empty.â l0b0
Jul 10 at 21:27
And
-f
checks if the following word is a regular file. Also, you can use -s
to check if a file is not empty.â l0b0
Jul 10 at 21:27
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%2f454561%2fwhat-does-this-if-statement-mean%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
A good reason you may not have seen
-a
or-o
is that they have been declared "obsolescent" by POSIX. Script authors are strongly encouraged to use the shell's&&
and||
insteadâ Fox
Jul 10 at 23:20
Oh i see. I always thought -a was for checking to see if a file exists.
â Aaron Tanenbaum
Jul 11 at 15:41