Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to append a value to a variable in shell script

Tags:

bash

shell

sh

I am getting a variable value from properties and I am able to access in sh file. but I am unable to append another value to that variable.

Kindly suggest.

$ echo "Build ID from properties:"$BUILD_ID
Build ID from properties: abcd_v6_c1

$ echo " num----------------" build_${BUILD_ID}.zip
.zip---------------- build_abcd_v6_c1

Kindly suggest how to append .zip value.

like image 425
sampath Avatar asked Oct 18 '25 10:10

sampath


1 Answers

Let's say we have a variablevar1=value. If I want to add some text to the beginning of the variable I can do:

var1="some text${var1}"

If I want to add some text to the end, it will be:

var1="${var1}some text"
like image 183
Alex Weitz Avatar answered Oct 20 '25 01:10

Alex Weitz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!