vech="London"
I'd like to add (append) "Bus" word to $vevh under UNIX scripting using bash?
You can simply use the following syntax:
vech="London" vech="$vech Bus" echo $vech
If you don't want to update $vech, but just want to print it on screen, enter:
echo "$vech Bus"
You can also append another variable:
x="Mango" y="Pickle" x="$x $y" echo "$x"
Finally:
x="Master" # print 'Master' without a whitespace i.e. print Mastercard as a one word # echo "${x}card"
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop







![Bash Shell Scripting Disable Control-C [ CTRL+C ] Keys](http://s0.cyberciti.org/images/rp/1/11.jpg)


{ 8 comments… read them below or add one }
What you are doing there is redefining it.
It’s completely useless.
When appending stuff to a variable, the most likely scenario is doing it while on a loop or an “if” block.
Redefining a variable in that context will just make it invisible once you get out of the loop or the “if” block.
Isn’t that response just as useless? You don’t provide an alternative.
Reply on old post but useful for someone who stumbles upon this
vech=”London”
vech=$vech” Bus”
echo $vech
Scratch that, should be
vech=”London”
echo $vech” Bus”
Jee thanks for Your site. Google frequently drives me here.
Sample given above does not work if there is no space:
vech=”Apple”
vech=”$vechseed”
echo $vech
^ ^ ^ Does not give you “Appleseed”
vech="Apple" vech="${vech}seed" echo "$vech"Thanks nixCraft! … Your example works for me and I think completes all possible scenarios that might apply to the original question. I also observed now in my experiment, the following produce expected results:
vech=”${vech}seed” # your original solution
vech=”${vech}+:;{[seed” # embed special syntax character works fine
vech=”${vech} seed” # embedding spaces also works fine
vech=${vech}”seed” # shifting the first double quote to the right
vech=${vech}” seed” # shifting the quote and embedding spaces
vech=${vech}”+:;{[seed” # shifted double quote w/special character