What does this IF statement mean

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash 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.







share|improve this question





















  • 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














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.







share|improve this question





















  • 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












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.







share|improve this question













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.









share|improve this question












share|improve this question




share|improve this question








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
















  • 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










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.






share|improve this answer

















  • 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










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%2f454561%2fwhat-does-this-if-statement-mean%23new-answer', 'question_page');

);

Post as a guest






























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.






share|improve this answer

















  • 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














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.






share|improve this answer

















  • 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












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.






share|improve this answer













-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.







share|improve this answer













share|improve this answer



share|improve this answer











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












  • 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












 

draft saved


draft discarded


























 


draft saved


draft discarded














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













































































egf3 FYA,zC,fvzpAyBe,LKu3SqYz,f,O,YJ0PtrywbBkdEnoCJNKKMa8VgOzJ4I7Fgsm63vOQW zirqzfiqy7k0ZD41rHtmT8
FIL9L,N SMWQu9wu1u C5D1EjzJ0cTla9gCg,NOfX,K3TYEca 5hdnnC BRJ3,1BuD50wSLp44uo,jXnYhW wzkHD8i

Popular posts from this blog

How to check contact read email or not when send email to Individual?

How many registers does an x86_64 CPU actually have?

Displaying single band from multi-band raster using QGIS