bash: Use regular expression to replace part of a variable value.



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

    Syntax is:
    ${name/pattern/string} replace first match of pattern with string.

    Here we replace the "Less" part of LessDeforestation with 2021

    $ echo $ClimateChange
    LessDeforestation
    $ Amazon=${ClimateChange/Less/2021}
    $ echo $Amazon
    2021Deforestation
    

Log in to reply
 

© Lightnetics 2024