How do I delete a string pattern in a variable using a bash shell script?



  • Usage is ${name/pattern}

    See line 3.

    declare -A MyBucketList
    MyBucketList=([1]="The rain in Spain stays mainly on the plain" [2]="Go to Mars" [3]="Climb Mount Everest")
    echo ${MyBucketList[3]/Mount}
    

    Running the script gives the following results. The word Mount is deleted from the variable.

    $ ./associative_array.sh
    Climb Everest
    

Log in to reply
 

© Lightnetics 2024