linux - Bash: comparing two strings issues -


i have written following bash script:

#!/bin/bash value="maria ion gheorghe vasile maria maria ion vasile gheorghe" value2="maria ion gheorghe vasile maria maria ion vasile gheorghe" if [[ "$value"!="$value2" ]];         echo "different"  else         echo "match" fi 

the problem script display "different" though strings stored in value , value2 variables not different. bash compare?

and, question related issue. let`s have:

v1 = grep 'a' a.txt v2 = grep 'a' b.txt 

can store , compare variables if grep results huge (lets more 50000 line each variabile)?

~

you need space around comparison operator in condition:

if [[ "$value" != "$value2" ]];         echo "different"  else         echo "match" fi 

if don't this, you're testing string - literally maria ion gheorghe vasile maria maria ion vasile gheorghe!=maria ion gheorghe vasile maria maria ion vasile gheorghe , condition evaluate true, yielding different.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -