The difference between integer & string comparison operators in bash scripts.



  • Take into account the main readme for this section. README first.

    Note: In some certain situations where a number can be taken as a string or an integer, then a string or integer operator will work but, use the right comparison operator for the right script operation.

    Interger type comparison operators eg:

    -ne, -eq, etc are used for integers

    The string comparison operators eg:

    ==, !=, <, >, etc are used for strings

    See the following from The Linux Documentation Project: https://www.tldp.org/LDP/abs/html/comparison-ops.html for a detailed list.



© Lightnetics 2024