How can I concatenate a shell variable to other other parameters in my command lines?For example,#!/bin/shWEBSITE=danydiop /usr/bin/mysqldump --opt -u root --ppassword $WEBSITE > $WEBSITE.sqlI need to concatenate .sql to $WEBSITE
How can I concatenate a shell variable to other other parameters in my command lines ?
shell script;shell;variable
Use ${ } to enclosure a variable.Without curly brackets:VAR=fooecho $VARecho $VARbarwould givefooand nothing, because the variable $VARbar doesn't exist.With curly brackets:VAR=fooecho ${VAR}echo ${VAR}barwould givefoofoobarEnclosing the first $VAR is not necessary, but a good practice.For your example:#!/bin/shWEBSITE=danydiop /usr/bin/mysqldump --opt -u root --ppassword ${WEBSITE} > ${WEBSITE}.sqlThis works for bash, zsh, ksh, maybe others too.