Write a bash script that takes a string, a pattern, and a replacement string as arguments and performs the following tasks:
Save the first command line parameter in a variable called input_string
.
Replace the first match of the pattern in the string with the replacement string.
Replace all matches of the pattern in the string with the replacement string.
./pattern_replace.sh "HelloWorldWorld" "World" "Universe"
Original string: HelloWorldWorld
First match replaced: HelloUniverseWorld
All matches replaced: HelloUniverseUniverse