Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

substring frequency

#To replace the first occurrence of a pattern with a given string,
#use ${parameter/pattern/string}:

#!/bin/bash
firstString="I love Suzi and Marry"
secondString="Sara"
echo "${firstString/Suzi/$secondString}"    

# prints 'I love Sara and Marry'

#To replace all occurrences, use ${parameter//pattern/string}:

message='The secret code is 12345'
echo "${message//[0-9]/X}"           
# prints 'The secret code is XXXXX'


#(This is documented in the Bash Reference Manual, §3.5.3 "Shell Parameter Expansion".)
Comment

PREVIOUS NEXT
Code Example
Shell :: bash script: replace . with : 
Shell :: install android repo 
Shell :: robotframework seleniumlibrary install 
Shell :: expo upgrade reset 
Shell :: linux permanent alias 
Shell :: how to start nessus on kali 
Shell :: merge gif with mp4 using ffmpeg 
Shell :: batch write to text file 
Shell :: ubuntu install java 16 
Shell :: vim move line down 
Shell :: linux my ip 
Shell :: ssh no strict checking 
Shell :: find folder in linux 
Shell :: pgadmin4 container 
Shell :: docker created network 
Shell :: optimize mp4 ffmpeg 
Shell :: remove space at end of line file 
Shell :: create csr ubuntu 
Shell :: install flask ubuntu 20.04 
Shell :: docker compose example 
Shell :: conda install open3d in specific environment 
Shell :: push all branches to remote 
Shell :: create xampp shortcut ubuntu 
Shell :: how to reset back to commit id in git 
Shell :: prettier yarn 
Shell :: how to check if a commit is in a branch 
Shell :: vim how to append to every line 
Shell :: create a virtual environment python 3.8 
Shell :: check size of hidden current directory linux 
Shell :: linux adb 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =