2

I have a piece of code like this:

count=0
until [ -f $filename -o $count -ge 60 ]
do
  count=$((count+1))
  sleep 1
done

I know [ -f $filename -o $count -ge 60 ] is a test command, "-f $filename" tests if the file exists or not, "$count -ge 60" tests if count is greater than or equal to 60, what does "-o" mean?

I googled, can't find the answer, anyone can help?

  • Try the help command for builtins: help test (help [ will tell you it's actually test). – muru Sep 22 '14 at 18:53
2

It's logical OR operator.

From bash documentation:

expr1 -o expr2
    True if either expr1 or expr2 is true.
0

It is a logical or operation. The code checks if $filename exists once/second for 60 seconds.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.