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
string with blank spaces psalas UNIX for Dummies Questions & Answers 4 04-16-2008 04:50 AM
sh, ksh: command to remove front spaces from a string? pseudocoder Shell Programming and Scripting 3 09-22-2007 07:57 AM
To remove Continous blank spaces from a file in UNIX arunkumar_mca UNIX for Dummies Questions & Answers 1 12-08-2006 01:10 AM
Variable has spaces around the string, need to remove them mikey20 Shell Programming and Scripting 4 10-13-2005 08:09 PM
how to remove spaces in a string using sed. radhika Shell Programming and Scripting 4 06-02-2005 03:00 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-02-2006
spandu spandu is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 7
remove blank spaces in a string

can any help how to remove blank spaces in a string?

STR="GOOD BYE"

by removing blank spaces, the string should be GOOD,BYE

thanks in advance
  #2 (permalink)  
Old 03-02-2006
gauravgoel gauravgoel is offline
Registered User
  
 

Join Date: Dec 2005
Location: India
Posts: 218
Quote:
echo $STR | awk '{print $1","$2}'
should work, i have not tested it
  #3 (permalink)  
Old 03-02-2006
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Well, according to that, you want to replace the space with a comma?

echo "$STR" | tr ' ' ','
echo "$STR" | sed 's/ /,/g' # g isn't strictly needed here

Cheers
ZB
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 01:03 AM.


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