How do I replace a string at the beginning of a variable using a bash shell script?
-
Usage is ${name/#pattern/string}
Check line 3
declare -A MyBucketList MyBucketList=([1]="To rain in Spain stays mainly on the plain" [2]="To get to Mars you need to air" [3]="Climb Mount Everest") echo ${MyBucketList[1]/#To/The}
The result is as follows, The
To
is replaced withThe
$ ./associative_array.sh The rain in Spain stays mainly on the plain
© Lightnetics 2024