Article 508VS Two conditions in "if" statement: if first fails, does it check second condition?

Two conditions in "if" statement: if first fails, does it check second condition?

by
ziphem
from LinuxQuestions.org on (#508VS)
I hope I don't embarrass myself with the question, and I presume the answer, but wanted to verify. I tried to look this up on Google, but wasn't sure how to properly describe it, and so couldn't find anything that gave an answer on it.

Question: when there are two conditions in an if / then statement with certain required matches, and the first match is not met, does the script then make a conclusion at that point? Or does it always check both conditions regardless?

So, for example:

Code:if [ "$item1" = 'A' ] && [ "$item2" = 'B' ]; then
echo "Success"
else
echo "Fail"
fiand $item1 does not equal A, does the script stop without checking the other condition and put me to "else"? Or will it always check the second condition [ "$item2" = 'B' ]?

Maybe more detail than anyone wants, but my reason: $item1 = From my computer, I want to check whether my phone is connected to the network - and this can be any network:
Code: nmap -T4 -A -v -oG - `/sbin/ip -o -4 addr list ***MY WIRELESS DEVICE*** | awk '{print $4}' | cut -d/ -f1 | grep -Po '.*(?=\.)'`.USUAL PORT RANGE -Pn -p PORT NUMBER WHERE PHONE WILL LISTEN | grep 'MY PHONE NAME' | grep -Pom 1 '[0-9.]{7,15}' | sort -u$item 2 = If it is, I verify with a test SSH. If $item1 fails, I don't want to send a test login to some random IP address on the network. For reference that test login:
Code:sshpass -p 'PASSWORD' ssh $PHONE -p PHONE'S SSH PORT -o ConnectTimeout=10 'exit 0' 2>&1 | grep 'TEXT OUTPUT WHEN SSHED IN'(I have a bunch of other protections in place - I only turn on my phone's Wifi and SSH server, check if I'm on a non-standard IP, check if on VPN, etc. etc. My script works now, just trying to clean up and simplify. I'll probably post the final code in case it benefits someone else.)

Thanks a ton!latest?d=yIl2AUoC8zA latest?i=0h5RBahJBt4:BNG0kYnEyhA:F7zBnMy latest?i=0h5RBahJBt4:BNG0kYnEyhA:V_sGLiP latest?d=qj6IDK7rITs latest?i=0h5RBahJBt4:BNG0kYnEyhA:gIN9vFw0h5RBahJBt4
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments