Answers for "replace string with a different string bash"

5

bash replace substring

echo [string] | sed "s/[original]/[target]/g"
Posted by: Guest on May-23-2020
0

bash replace substring in string

#!/bin/bash
firstString="I love Suzi and Marry"
secondString="Sara"
echo "${firstString/Suzi/$secondString}"    
# prints 'I love Sara and Marry'
Posted by: Guest on April-29-2021
0

bash replace string

#1) Open the file in vi or vim
#2) Run the replacement command in vi (or vim) as follows

# Replace all matching patterns
:s%/PatternToReplace/Replacement

# Replace one matching pattern at a time
:s/PatternToReplace/Replacement
Posted by: Guest on November-17-2021

Code answers related to "replace string with a different string bash"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language