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
swap words in a line with sed atticus Shell Programming and Scripting 9 09-13-2008 12:09 PM
swaping of first 2 words in every line using sed web123 Shell Programming and Scripting 4 05-28-2008 10:02 AM
count no of words in a line satish@123 Shell Programming and Scripting 7 05-21-2008 03:59 AM
How to append words at the end of first line lmatlebyane Shell Programming and Scripting 11 02-28-2008 04:39 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 11:48 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 06-26-2007
skyineyes skyineyes is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 150
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
  #2 (permalink)  
Old 06-26-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

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.
  #3 (permalink)  
Old 06-26-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,433
You can do something like that :

Code:
line=+abc+def+mgh+ddsdsd+sa"
new_line=$(echo "$line" | sed 's/^+//;s/+/, /g')

  #4 (permalink)  
Old 06-26-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398

Code:
str="+abc+def+mgh+ddsdsd+sa"
echo ${str#?} | tr '+' ','

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:38 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