I am trying to add a variable to the middle of a variable, so for instance in PHP I would do this:
$mystring = $arg1 . '12' . $arg2 . 'endoffile';
so the output might be 20121201endoffile, how can I achieve the same in a linux bash script?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try doing this, there’s no special character to concatenate in bash :
explanations
If you don’t put brackets, you will ask bash to concatenate
$arg112 + $argendoffile(I guess that’s not what you asked) like in the following example :The brackets are delimiters for the variables when needed. When not needed, you can use it or not.
another solution
(less portable : require
bash> 3.1)See http://mywiki.wooledge.org/BashFAQ/013