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.

  • 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, 2018 at 23:20
  • Oh i see. I always thought -a was for checking to see if a file exists. Jul 11, 2018 at 15:41

1 Answer 1


-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, 2018 at 21:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .