Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

shell: search a string if it contains another string

# Search for a substring in another string using wildcard

string='My long string'
substr='My long'

# Note: the wildcard character (*) is outside the double qoute ("")
if [[ "$string" == *"$substr"* ]]; then
  echo "Found substring!"
fi
Comment

PREVIOUS NEXT
Code Example
Shell :: apache config directory 
Shell :: fatal: unable to access Could not resolve host wsl 
Shell :: java check java version 
Shell :: ls | wc -l in other directory 
Shell :: keyboard abnt2 arch linux 
Shell :: -bash: jupyter: command not found linux 
Shell :: plasma 
Shell :: restart nginx in mac 
Shell :: how to check free space in linux 
Shell :: git rename remote 
Shell :: install mongo db ubuntu 
Shell :: reactjs capacitor init 
Shell :: install .deb file in ubuntu 
Shell :: clear history linux 
Shell :: ngx translate install 
Shell :: linux opened ports 
Shell :: notebook 
Shell :: bash view the contents of a sqfs file 
Shell :: shell remove last character 
Shell :: git remove from from repo and stop tracking 
Shell :: pip install requirements.txt 
Shell :: bash command check 2 arguments 
Shell :: install react-native cmd linux 
Shell :: pip install bs4 pip install --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org 
Shell :: read password bash 
Shell :: check swiftly version linux 
Shell :: create new item from terminal 
Shell :: Scan Existing disk in linux 
Shell :: git config --global remove 
Shell :: terminal list items in directory 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =