Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

replace all instances

#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 :: how to restart network manager in kali 
Shell :: How to see my aliases? 
Shell :: select latest file linux 
Shell :: wget from text file 
Shell :: linux screen run jar 
Shell :: npm install firebase-admin 
Shell :: port already in use 8000 
Shell :: ubuntu 20.04 wifi adapter not found dell 
Shell :: run command on startup neovim 
Shell :: linux remove all files same extension in directory 
Shell :: windows find node path 
Shell :: mongodb server stop command in kali linux 
Shell :: update metsploit kali linux 
Shell :: linux see group memebers 
Shell :: kill port 
Shell :: reduce file size of mp4 using ffmpeg 
Shell :: shell script in jenkins pipeline 
Shell :: Add Subtitles (.SRT file) To MP4 With FFMPEG 
Shell :: install homebrew on mac 
Shell :: find image size terminal 
Shell :: git delete unstaged files 
Shell :: searching for a git folder 
Shell :: remove tracked files git 
Shell :: stop all docker containers 
Shell :: install prettier globaly 
Shell :: install leafpad ubuntu 2021 
Shell :: bash vim how to append text to every line 
Shell :: how to add a gif to your website 
Shell :: snap install package 
Shell :: install rancher 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =