bash: Use regular expression to match and replace pattern at the end of a variable value.



  • Take into account the main readme for this section. README first.

    Syntax is:
    ${name/%pattern/string} match and replace pattern at the end of a variable value.

    $ echo $ClimateChange
    2021NoDeforestation2021
    $ Amazon=${ClimateChange/%2021/2020}
    $ echo $Amazon
    2021NoDeforestation2020
    

Log in to reply
 

© Lightnetics 2024