Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash substring test

#!/bin/bash

STR='GNU/Linux is an operating system'
SUB='Linux'
if [[ "$STR" == *"$SUB"* ]]; then
  echo "It's there."
fi
Comment

bash substring test

#!/bin/bash

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

if grep -q "$SUB" <<< "$STR"; then
  echo "It's there"
fi
Comment

bash substring test

#!/bin/bash

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

if [[ "$STR" =~ .*"$SUB".* ]]; then
  echo "It's there."
fi
Comment

bash substring test

#!/bin/bash

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

case $STR in

  *"$SUB"*)
    echo -n "It's there."
    ;;
esac
Comment

PREVIOUS NEXT
Code Example
Shell :: timestamp in bash 
Shell :: delete first column bash 
Shell :: how to set up git for github 
Shell :: remove dbeaver ubuntu 7.1.5 
Shell :: wsl System has not been booted with systemd as init system 
Shell :: github how to clone private repo 
Shell :: replace all instances 
Shell :: install mariadb amazon linux 2 
Shell :: linux screen run jar 
Shell :: elevated privileges windows 10 
Shell :: batch write to text file 
Shell :: Please commit your changes or stash them before you merge 
Shell :: how to get list of users in ubuntu 
Shell :: how to uncommit last commit in git 
Shell :: ffmpeg overwrite 
Shell :: linux see group memebers 
Shell :: jq to csv 
Shell :: tailwind nodejs 
Shell :: how to split a string in bash 
Shell :: Failed to start The Apache HTTP Server. 
Shell :: install pip dockerfile 
Shell :: install oh my zsh linux 
Shell :: git fetch and checkout branch 
Shell :: install rails 
Shell :: windows how to access wsl from explorer 
Shell :: git display current head 
Shell :: docker run in the background 
Shell :: install discord bot on server 
Shell :: linux remove last n lines from file 
Shell :: pesquisar codigo commit 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =