The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Concatenate lines in a single paragraph cgkmal Shell Programming and Scripting 4 05-17-2009 02:02 AM
joining 2 lines into single one ali560045 Shell Programming and Scripting 3 10-16-2008 09:56 AM
Dividing single file by lines? anoc Shell Programming and Scripting 1 04-08-2008 02:08 PM
removing lines with single charector balaji_prk Shell Programming and Scripting 4 09-17-2007 03:23 AM
Reading multiple lines as single braindrain Shell Programming and Scripting 9 10-18-2006 11:16 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-24-2009
umesh.rout umesh.rout is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 4
Add two lines in a single string

Dear All,

I want to add two lines in single string.

Example:
String1: God Bless You.
String2: Thank You.

Now i want to store these two above lines into a single string(str) and when i will echo it, it should be like
> echo $str
God Bless You.
Thank You.

Please help me.
Thanks in advance...
  #2 (permalink)  
Old 08-24-2009
scottn scottn is online now Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,057
Separate them with a \n character.

Code:
string="string_1\nstring_2"
And echo them:
Code:
echo $string
In Linux you may need to use the -e flag:

Code:
echo -e $string
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:33 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0