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 :: linux check current umask 
Shell :: git pull rebase command 
Shell :: react native cannot connect to metro server 
Shell :: babel source maps 
Shell :: install deno 
Shell :: rescale kubectl 
Shell :: instalar webmin ubuntu 20.04 
Shell :: rmdir multiple directories 
Shell :: bash create user with encrypted password 
Shell :: docker logs path 
Shell :: git switch branch 
Shell :: ffmpeg change audio codec from m4a to mp3 
Shell :: git unstash 
Shell :: linux kali download 
Shell :: kubectl kubernetes port forward 
Shell :: develop - FETCH_HEAD instead of origin develop 
Shell :: npm help 
Shell :: folder open in command line 
Shell :: npm install, npm install for web developer 
Shell :: sh: webpack-dev-server: command not found 
Shell :: git interactive rebase 
Shell :: command to check the amount of disk space used 
Shell :: redirect stderr to file linux 
Shell :: mac force quit shortcut 
Shell :: install virtualbox 
Shell :: add user with sudoer centos 
Shell :: terraform 
Shell :: connect to wifi with wpa supplicant raspberry pi 
Shell :: bash mkdir multiple 
Shell :: there are stopped jobs 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =