How does if statement behave in bash?

by Simmons (Login simmons_josh)
R

 

This is an example from stack exchange on determining if files are similar or not.

if cmp -s "$file1" "$file2"
then
echo "The files match"
else
echo "The files are different"
fi


From what I understand cmp returns 0 if the files are the same and non zero of they are different. So according to that example does bash if statements consider 0 to be true?

Posted on Feb 23, 2018, 6:49 PM

Respond to this message   

Return to Index

 Copyright © 1999-2018 Network54. All rights reserved.   Terms of Use   Privacy Statement  

Quantcast