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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
swaping of first 2 words in every line using sed web123 Shell Programming and Scripting 4 05-28-2008 06:02 AM
count no of words in a line satish@123 Shell Programming and Scripting 7 05-20-2008 11:59 PM
How to append words at the end of first line lmatlebyane Shell Programming and Scripting 11 02-28-2008 12:39 AM
swap words in a line with sed atticus Shell Programming and Scripting 8 09-08-2006 07:42 AM
How to grep for two or more words in a line at the same time? ElCaito Shell Programming and Scripting 2 03-01-2006 07:48 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-26-2007
Registered User
 

Join Date: Jun 2007
Posts: 111
seperating the words from a line??

The line is like this
+abc+def+mgh+ddsdsd+sa
i.e. words seperated by +. There is a plus in the beginning.

i want to conver this line to
abc, def, mgh, ddsdsd, sa

please provide the logic in the form of a shell script


Thanks in advance
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-26-2007
Shell_Life's Avatar
Unix/Informix/4GL/SQL
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Skyineyes,
Do not break the rules duplicating posts:
http://www.unix.com/shell-programmin...-required.html
You will just make it more difficult for you to find a solution.
Give time to the members to work on the issue.
Reply With Quote
  #3 (permalink)  
Old 06-26-2007
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,158
You can do something like that :
Code:
line=+abc+def+mgh+ddsdsd+sa"
new_line=$(echo "$line" | sed 's/^+//;s/+/, /g')
Reply With Quote
  #4 (permalink)  
Old 06-26-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Code:
str="+abc+def+mgh+ddsdsd+sa"
echo ${str#?} | tr '+' ','
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:45 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0