develog

[bash] existStr 본문

OS & Shell/bash

[bash] existStr

냐옴 2019. 2. 15. 12:00

existStr

existStr() {

    if [[ $1 == *"$2"* ]]; then

        echo true

    else

        echo false

    fi

}


ret1=$(existStr "Server start up in" "start")

ret2=$(existStr "Server start up in" "Start")


if $ret1; then

    echo "ret1 is true"

else

    echo "ret1 is false"

fi


if $ret2; then

    echo "ret2 is true"

else

    echo "ret2 is false"

fi


# output

ret1 is true

ret2 is false 


'OS & Shell > bash' 카테고리의 다른 글

[bash] tmux  (0) 2020.09.16
[bash] 다중 명령 실행 && || ;  (0) 2020.09.15
[bash] 로컬 shell script 파일을 원격 서버에서 실행하기  (0) 2019.02.26
[bash] function return  (0) 2019.02.15
[bash] kill ps grep awk  (0) 2019.02.15
Comments