Need some help interpreting the result of this command. Results don’t seem to be intuitive.
- I ran the following and it evaluates the “if” block:
root@kali:/tmp# if [[ 0 ]]; then echo “return true”; else echo “return false”; fi
return true
- Now, I have two files with same content, test1.txt and test2.txt
root@kali:/tmp# echo test > test1.txt
root@kali:/tmp# cp test1.txt test2.txt
- I would expect the following to run the “if” block, but it executes the “else” block. I am not sure why, especially in step 1 the same thing executes the “if” block.
root@kali:/tmp# if [[ $(diff test1.txt test2.txt) ]]; then echo “return true”; else echo “return false”; fi
return false
I am missing something, but not sure what. Thanks in advance!