Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concat strings in a shell script [duplicate]

How can I concat strings in shell? Is it just...

var = 'my'; var .= 'string'; 

?

like image 424
Webnet Avatar asked Feb 25 '12 15:02

Webnet


People also ask

What is ${} in shell script?

${} Parameter Substitution/Expansion A parameter, in Bash, is an entity that is used to store values. A parameter can be referenced by a number, a name, or by a special symbol.

How do you concatenate 2 strings?

You concatenate strings by using the + operator. For string literals and string constants, concatenation occurs at compile time; no run-time concatenation occurs. For string variables, concatenation occurs only at run time.

How do you concatenate in a Unix script?

String concatenation is the process of appending a string to the end of another string. This can be done with shell scripting using two methods: using the += operator, or simply writing strings one after the other.


1 Answers

How about this:

var="${var}string" 
like image 117
cnicutar Avatar answered Sep 30 '22 10:09

cnicutar