Compare string in BASH - LinuxConfig.org

The need to compare strings in a Bash script is relatively common and can be used to check for certain conditions before proceeding on to the next part of a script. A string can be any sequence of characters. To test if two strings are the same, both strings must contain the exact same characters and in the same order. It could be a word or a whole sentence. For example, string one is equal to string one but is not equal to string two. Get the idea?


This is a companion discussion topic for the original entry at https://linuxconfig.org/compare-string-in-bash