scnzzh@zubt1:~/zzh$ str='I love python and python.' scnzzh@zubt1:~/zzh$ echo ${str/'python'/'shell'} I love shell and python. scnzzh@zubt1:~/zzh$ echo ${str/python/shell} I love shell and python. scnzzh@zubt1:~/zzh$ echo ${str//python/shell} I love shell and shell.
To replace all occurrences, use ${parameter//pattern/string}.