0

I am looking to declare variables to have an output of—for my email subject:

value_value_value_value_value

I would need my variable outputs to have spaces in between, I am trying to add email subject using the variable. Please see my code:

var1=$1
var2=$2
var3=$3
var4=$4$5$6


echo "email content

$var2 $var3

email content $ticketnumber

email content,
" | mail -s  $var4  testmail@gmail.com -- -f testmail@gmail.com
user127192
  • 25
  • 4
  • 2
    Possible duplicate of [Bash script variable declaration - command not found](http://stackoverflow.com/questions/2268104/bash-script-variable-declaration-command-not-found) – user3502626 Oct 19 '16 at 02:25
  • I don't really understand what your trying to do. you can also try sed. http://stackoverflow.com/questions/3306007/replace-a-string-in-shell-script-using-a-variable – user3502626 Oct 19 '16 at 02:27
  • I am trying to automate my email sending—I need my subject to be a variable as its not a constant—when I am outputting my subject it doesn't have spaces. Thanks! – user127192 Oct 19 '16 at 02:34

1 Answers1

0

You can use the following code to concatenate your variables:

var4="$var4"_"$var5"_"$var6"

The _ inbetween the variables is as per your original question, not as reflected in your sample code.

If you need spaces, you can change it to:

var4="$var4"" ""$var5"" ""$var6"
roelofs
  • 2,132
  • 20
  • 25