User Tools

Site Tools


shell_scripting_notes

compare strings

tags | string comparison, compare strings, if else condition

#! /usr/bin/env bash

terminal_type=`uname -s | cut -f 1 -d '-'`
if [ "$terminal_type" = "MINGW64_NT" ];
then
    echo "using git bash terminal"
elif [ "$terminal_type" = "CYGWIN_NT" ];
then
    echo "using cygwin terminal"
else
    echo "unknown terminal"
fi

# Ref:
# * https://stackoverflow.com/questions/2237080/how-to-compare-strings-in-bash
#  * explains why the quotes (ex:- "$terminal_type") are important.

ref:-

shell_scripting_notes.txt · Last modified: 2021/08/11 22:05 by raju