xpt
xpt

Reputation: 23034

What's Linux test -a command test for?

Please take a look at the following code,

snap=snapshot.file   
touch snapshot.file-1

$ [ -a $snap-1 ] && echo yes 
yes

What does the test -a command tests for here?

I tried info coreutils 'test invocation' and searched for -a, but didn't find it in the file characteristic tests section, but rather in the connectives for test section.

Is such test -a command an undocumented one?

Upvotes: 0

Views: 171

Answers (1)

Martin Konecny
Martin Konecny

Reputation: 59681

-a is used for an and expression. You would usually use it with two operands:

$[ $snap0 -a $snap1 ]

not sure what context it is used in here, but it's possible that someone removed the first operand without removing the -a operator.

Upvotes: 1

Related Questions