Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-10-2012
Registered User
 
Join Date: Jun 2012
Location: Austin, TX
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
sed problem

Hi Folks,

I want to replace these numbers with words as the following:

$echo 1 11 223

I want to replace each number with it name (e.g. "1" replaced with "one", etc.) just to determine how sed works in such case. Thanks in advance.

Leo
Sponsored Links
    #2  
Old 06-10-2012
balajesuri's Avatar
#! /bin/bash
 
Join Date: Apr 2009
Location: India
Posts: 1,574
Thanks: 15
Thanked 441 Times in 426 Posts
So, you want to replace 223 with "two hundred and twenty three" ???
Sponsored Links
    #3  
Old 06-10-2012
Registered User
 
Join Date: Jun 2012
Location: Austin, TX
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Hi Balajesuri, Exactly! I just want to know the idea of replacing the number in 'sed' query, what I've been write above is just a very simple example to put my idea on the table. I do appreciate your replay. thanks and still looking for a solution.
    #4  
Old 06-10-2012
bartus11's Avatar
Registered User
 
Join Date: Apr 2009
Posts: 3,146
Thanks: 3
Thanked 957 Times in 936 Posts
It can be done easily with Perl: Lingua::EN::Numbers - search.cpan.org
Sponsored Links
    #5  
Old 06-10-2012
Registered User
 
Join Date: Jun 2012
Location: Austin, TX
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Thanks Bartus for your valued support, but I'm looking for the solution with sed it self, please consoder what I've done as the following:
example.
Quote:
sed -e "s/'4'/'OFFICIAL_RATE'/g"
this change every (4)s that sed fine it even if it within number (e.g. 414=OFFICIAL_RATE1OFFICIAL_RATE), I',m looking to change the 4 only as a single character, hope this is clear, still waiting for your support please. Thanks

Leo
Sponsored Links
    #6  
Old 06-10-2012
bartus11's Avatar
Registered User
 
Join Date: Apr 2009
Posts: 3,146
Thanks: 3
Thanked 957 Times in 936 Posts
Try:
Code:
sed -e "s/\<4\>/OFFICIAL_RATE/g"

Sponsored Links
    #7  
Old 06-11-2012
Registered User
 
Join Date: Jun 2012
Location: Austin, TX
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by bartus11 View Post
Try:
Code:
sed -e "s/\<4\>/OFFICIAL_RATE/g"

Still not working!! I found 4 not OFFICIAL_RATE in the output!!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem with forwarding emails (SPF problem) carwe IP Networking 0 08-16-2011 06:17 AM
DHCP problem and eth1 problem sllinux UNIX for Dummies Questions & Answers 0 10-23-2009 02:45 AM
Mail Problem. Maybe, it is a DNS Problem! pintalgi Red Hat 1 07-19-2009 04:01 PM
user login problem & Files listing problem. pernasivam AIX 1 06-18-2009 09:09 AM
problem in finding a hardware problem girish.batra Solaris 8 09-09-2008 10:10 AM



All times are GMT -4. The time now is 05:46 PM.