Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

find index of string in shell

# To find the index of a substring in another string
# Take for instance, below take two strings: str and substr. 

str="hello world"
substr="world"
 
prefix=${str%%$substr*}
index=${#prefix}
 
if [[ index -eq ${#str} ]];
then
    echo "Substring is not present in string."
else
    echo "Index of substring in string : $index"
fi

Comment

PREVIOUS NEXT
Code Example
Shell :: batch comment 
Shell :: create next app with jest 
Shell :: react native doest reload 
Shell :: check difference between two branches git 
Shell :: awk and grep in linux for waht 
Shell :: docker gpio 
Shell :: delete all feature branches 
Shell :: rmdir recursive 
Shell :: how to ls git branch 
Shell :: save command output to file in powershell 
Shell :: installing dbeaver 
Shell :: if statement bash 
Shell :: install node_modules folder 
Shell :: jq list top nodes 
Shell :: nextjs start production 
Shell :: créer un script linux 
Shell :: grpc client 
Shell :: example bash script 
Shell :: git hub 
Shell :: install raspberry pi 
Shell :: dir /s cmd 
Shell :: git commands cheat sheet 
Shell :: add shortcut to applications ubuntu 
Shell :: shell themes for ubuntu 
Shell :: mac terminal screenshot 
Shell :: bash if else if 
Shell :: install gitlab runner 
Shell :: java status archlinux 
Shell :: LF will be replaced by CLRF 
Shell :: kali linux ffuf fuzzingvirtual hosts 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =