Series: Subject: Topic:
Question: 112 of 183

Unix command to concatenate (attach) two strings?

Asked by: Interview Candidate | Asked on: Jul 10th, 2006
Showing Answers 1 - 7 of 7 Answers
Madhuker Sinha

Answered On : Jul 20th, 2006

For concatenating two string we use cat command.Ex:- cat str1 str2

Login to rate this answer.

Answered On : Aug 1st, 2006

echo $var1 $var2

Login to rate this answer.

Answered On : Aug 2nd, 2006

View all answers by kkamatam

Cat $str1 $str2 is WRONG - cat command will need file names as input

Login to rate this answer.
Asha Sonani

Answered On : Aug 25th, 2006

var1=$var1$var2echo $var1

Login to rate this answer.
Ramya Murthy

Answered On : Nov 2nd, 2006

You can concatenate two strings by using the echop command..echo -e -n str1; echo str2 | cat

Login to rate this answer.

Variable1="Open"Variable2="Systems"Variable3=$Variable1$Variable2echo $Variable3-- Output OpenSystems

Yes  1 User has rated as useful.
Login to rate this answer.

Answered On : Aug 26th, 2009

View all answers by Markerhell

There are two different ways to do the same.1. var1 = "first"var2 = "second"var3 = $var1$var2The only problem with the above solution is you can not attach the general text at hte end or in between of the text to create new string as variable which is not present so it will give an error.BEST SOLUTION IS:2. var1 = "first"var2 = "second"var3 = ${var1}$var2This will also work. In addtion to this, if you want to add some general text, you can add.ex. var3 = $var1${var2}thisistestaddditionthe var3 will be firstsecondthisistestadddition

Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions



twitter fb Linkedin GPlus RSS


Interview Question

 Ask Interview Question?


Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.