The following bash command:
aws s3 ls s3://bucket/dir | grep _SUCCESS | wc -l
prints:
0
What I want is, when the result is indeed 0, to print FAILURE to the terminal.
This is what I've tried:
if [ aws s3 ls s3://bucket/dir | grep _SUCCESS | wc -l = 0]; then echo FAILURE; fi
but nothing is printed. it looks like it is waiting for more input.
You should use command substitution:
or in a line:
Better solution as "@steeldriver" suggested use using grep's exit status :
or: