Answers for "bash sh if string contains"

4

check if variable contains string bash

STRING='Hello world'
if [[ $STRING =~ "Hello" ]] ; then echo "It's here" ; fi
Posted by: Guest on April-17-2021
4

bash string contains

#!/bin/bash

STR='GNU/Linux is an operating system'
SUB='Linux'
if [[ "$STR" == *"$SUB"* ]]; then
  echo "It's there."
fi
Posted by: Guest on June-29-2020

Code answers related to "bash sh if string contains"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language