Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash index of string

# 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 :: query in github api 
Shell :: viu linux 
Shell :: ubuntu livepatch fail 
Shell :: jinja escape 
Shell :: npm install react-navigation-stack 
Shell :: git untract file 
Shell :: command running processes linux 
Shell :: create file linux 
Shell :: install macos on vmware ubuntu 
Shell :: download gif 
Shell :: jenkins download 
Shell :: delete merge branch git 
Shell :: git remove file 
Shell :: how to access the local machine using WSL 
Shell :: command to kill or terminate a process 
Shell :: linux how to execute a script 
Shell :: piping commands 1 
Shell :: how to connect mongocell in ubuntu 
Shell :: toasty android github 
Shell :: powershell command line variables 
Shell :: grep output options 
Shell :: upload on s3 
Shell :: force push to remote branch 
Shell :: aws s3 change bucket region 
Shell :: pacman command on arch 
Shell :: github cli download 
Shell :: fslmaths 
Shell :: How to clean up the git repo and reduce its disk size 
Shell :: tiny core shutdown 
Shell :: hanselman pretty prompt 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =