I am a new bash
learner. I want to know, how to replace a letter with another in bash
.
The task is: I have to take some strings from standard input. Then I have to process every string. For one string, I have to replace the first occurrence of capital letter with .
.
Say the input is like the following:
Namibia
Nauru
Nepal
Netherlands
NewZealand
Nicaragua
nIgEr
Nigeria
NorthKorea
Norway
The output should be like:
.amibia .auru .epal .etherlands .ewZealand .icaragua n.ger .igeria .orthKorea .orway
As far I could do:
countries=()
while read -r country; do
# here I have to do something to detect the first occurrence of capital letter and then replace it with a dot(.)
countries+=( "$country" )
done
echo "${countries[@]}"
Please, help.