bash - Linux Script error with comparing strings -


i'm trying take 2 string input , check if equal or not, if not equal tell character length. i'm getting not found error after type 2 strings, can tell doing wrong? tried using:

    #!/bin/bash     while true;     echo "please enter 2 name compare"     read name_1 name_2     1=${#name_1}     2=${#name_2}      if [ "$name_1" -eq  "$name_2" ]            echo "$name_1 , $name_2 equal"     else       echo "$name_1 , $name_2 not equal"     fi      echo "string 1 length $(1)"                 echo "string 2 length $(2)"      done 

points:

  • a user defined variable in bash can not start digit , can not digit

  • -eq arithmetic comparison; comparing strings use = (posix) or ==


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -