Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2008
    Posts
    7

    Unanswered: Error in String comparison

    Hi,
    I am getting an error while executing the below code.
    The error is " [: too many arguments "
    string1="material layout"
    string2="material layout"

    if [ $string1 == $string2 ]
    then
    echo "Strings are equal"
    fi

    Please help me to solve this error

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    You need to quote your variables i.e.
    if [ "$string1" = "$string2" ]

  3. #3
    Join Date
    Oct 2008
    Posts
    7
    Thanks a lot. It is working now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •