Search code examples
linuxbashshellunix

How to compare 2 strings in cli (in one line)


Wanted to evaluate things like following quickly

"84fbe59c20f52b43125f76a9101e373f775a75b89435cdda301a63694c69c2da" == "84fbe59c20f52b43125f76a9101e373f775a75b89435cdda30
1a63694c69c2da" // extected to get something like true or 1

How to do that in one line? Don't want to create a file to check that. Seen that stack-overflow has many Q&A similar to this but all of those works with a file where my intention is to check this out quickly & without any file creation.


Solution

  • I tested this in Git Bash and all good

    [ "84fbe59c20f52b43125f76a9101e373f775a75b89435cdda301a63694c69c2da" == "84fbe59c20f52b43125f76a9101e373f775a75b89435cdda301a63694c69c2da" ] && echo "true" || echo "false"