Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need to compare two report names, that is, two strings.
When I tried to use the following expression:
if (( $word1 -eq $rptname ))
or
if [[ $word1 -eq $rptname ]]system report: syntax error
If I use the following expression:
if ( $word1 -eq $rptname )System seems to think the two strings are different, but they are the same, I can see use ECHO command.
Can anyone kindly advise the correct expression? Or maybe there is some other thing wrong?
Thanks!

-eq is for matching integers, and (()) is for integer expressions.
Try
if [[ $word1 = $rptname ]]
then
print Match
else
print No match
fiFor integers you could use
integer int1=1 int2=2
if (( int1 == int2 ))
then
print Match
else
print No match
fiNote that '=' becomes an assignment operator inside (()).

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |