Horje
bash string contains Code Example
bash string contains
#!/bin/bash

STR='GNU/Linux is an operating system'
SUB='Linux'
if [[ "$STR" == *"$SUB"* ]]; then
  echo "It's there."
fi
Source: linuxize.com
checking if a substring exists in a string bash
string='Haystack';

if [[ $string =~ "Needle" ]]
then
   echo "It's there!"
fi
bash substring test
#!/bin/bash

STR='GNU/Linux is an operating system'
SUB='Linux'

if [[ "$STR" =~ .*"$SUB".* ]]; then
  echo "It's there."
fi
Source: linuxize.com




Shell

Related
how to install bootstrap in react Code Example how to install bootstrap in react Code Example
cisco save running config Code Example cisco save running config Code Example
netstat centos ports Code Example netstat centos ports Code Example
install pecl on mac Code Example install pecl on mac Code Example
how to clone my linux so all the installed packages Code Example how to clone my linux so all the installed packages Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
18