Home > OS >  /great god come in, please consult a while read nested if statements problem!!!!!!!!!!!
/great god come in, please consult a while read nested if statements problem!!!!!!!!!!!

Time:10-20

While I read the nested in an if statement, but the judge seems doesn't work!
 
The cat file. TXT
ABC
Def
Ghi
====================
The cat file. TXT | while read the line; Do
If the [[${line} - eq "ABC"]]. Then
Echo "yes"
The else
Echo "no"
Fi
The done


Typing is yes, like a statement didn't work, don't know what's the matter, for a great god grant instruction!!!!!

CodePudding user response:

Eq is used for comparison of integer, string comparison with=directly by the
 ${line}="ABC" 

CodePudding user response:

Eq is the comparison of the integer
String comparison==
 
The cat file. TXT | while read the line; Do
If the [[${line}=="ABC"]]. Then
Echo "yes"
The else
Echo "no"
Fi
The done
  • Related