|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Adding more text to a variable
Is there a more simple way to add text to a variable I have Code:
var="blue" and like to add green to get Code:
echo $var blue green Here is how I do it. Code:
var=$(echo "${var} green")---------- Post updated at 13:23 ---------- Previous update was at 13:12 ---------- UffNot always easy to see the simple... This works fine Code:
var="${var} green" |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Note that the braces aren't needed either unless what you want to add to the variable could be interpreted by the shell to be part of the variable name. Code:
var=blue
echo "$var"
var="$var green"
echo "$var"
var="${var}red"
echo "$var"produces Code:
blue blue green blue greenred |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [bash help]Adding multiple lines of text into a specific spot into a text file | cdn_humbucker | Shell Programming and Scripting | 2 | 03-06-2010 02:11 AM |
| adding value to variable using expr | Kochu77 | Shell Programming and Scripting | 2 | 11-22-2008 07:39 AM |
| Adding specific text and spaces to each line in a text file | hertingm | Shell Programming and Scripting | 4 | 08-25-2008 02:34 PM |
| adding spaces for a variable value | dnat | Shell Programming and Scripting | 2 | 02-26-2008 04:32 AM |
| adding 0 to a variable | shivakundan | Shell Programming and Scripting | 3 | 02-14-2007 09:05 PM |
|
|