cmp in if statement (Bash)

Viewed 2319
if [ cmp -s "$expectedOut" "$actualOut" ]; then

The following line of code keeps giving me errors saying that there are too many arguments. however I know this is the proper typical use of cmp so I think it may have to do with the brackets. Anyone know whats really going on here?

1 Answers

Lose the [ ].

if cmp -s "$expectedOut" "$actualOut" ; then

The syntax of if is

if Command; then

[ is just one possible command (on that happens to expect ] as its last argument to make things look pretty).

Related