Bash – What does -s and [[]] mean in an if condition in bash

bashshell-script

if [[ -s log.txt ]];

What does -s mean? I know -z means zero sized string. I cannot find any documentation on -s.

What does [] or [[]] mean, while writing an if condition. I have used if without [] or [[]] and it worked fine.

Best Answer

The -s test returns true if

[...] if file exists and has a size greater than zero

This is documented in the bash manual, and also in the manual for the test utility (the test may also be written if test -s file; then).

For [ ... ] and [[ ... ]], see: Bash - If Syntax confusion

Related Question