The UNIX and Linux Forums  

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
Delete Multiple White Spaces eja UNIX for Dummies Questions & Answers 6 04-18-2008 07:34 AM
trimming white spaces briskbaby Shell Programming and Scripting 9 09-23-2006 07:10 PM
Trim white spaces using awk mona Shell Programming and Scripting 2 07-28-2006 05:47 AM
delete white spaces DebianJ Shell Programming and Scripting 2 10-12-2005 02:30 PM
deleting white spaces cary530 UNIX for Dummies Questions & Answers 10 02-17-2004 01:22 PM

Closed Thread
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 10-04-2006
harish_oty harish_oty is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 4
Two or more white spaces in string

Hi,

Can anybody suggest me how to combine two strings with two or more white spaces and assign it to a variable?
E.g.
first=HAI
second=HELLO
third="$first $second" # appending strings with more than one white spaces

echo $third

this would print
HAI HELLO

Output appears with only one white space.

TIA.
Regards,
Harish
  #2 (permalink)  
Old 10-04-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
I think the default IFS is defined to be a whitespace. So you can change the IFS to a newline and then output the desired variable
Code:
first=HAI
second=HELLO
oldifs="$IFS"
IFS='
'
third="$first $second"
echo $third
IFS="$oldifs"
Not tested tho'.
  #3 (permalink)  
Old 10-04-2006
harish_oty harish_oty is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 4
Vino,

It is working fine. Thanks.

Regards,
Harish
Closed Thread

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 02:29 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