Sponsored Content
Top Forums Shell Programming and Scripting How to convert number to english? Post 302935519 by drl on Tuesday 17th of February 2015 08:40:27 AM
Old 02-17-2015
A perl alternative

Hi.

For Don's data file, augmented, in file data2:"
Code:
0
1
11
111
1,011
1_012
123000000456000000789
1000000000000000000000023
2034500
975310000000000000000000000987654321
1000000000000000000000000000000000000

the perl code:
Code:
perl -M"Lingua::EN::Numbers qw(num2en num2en_ordinal)" -n -e 'chomp;
print " Cardinal for $_: ",num2en($_),"\n";
print " Ordinal  for $_: ", num2en_ordinal($_),"\n";' data2

produces:
Code:
 Cardinal for 0: zero
 Ordinal  for 0: zeroth
 Cardinal for 1: one
 Ordinal  for 1: first
 Cardinal for 11: eleven
 Ordinal  for 11: eleventh
 Cardinal for 111: one hundred and eleven
 Ordinal  for 111: one hundred and eleventh
 Cardinal for 1,011: one thousand and eleven
 Ordinal  for 1,011: one thousand and eleventh
 Cardinal for 1_012: 
 Ordinal  for 1_012: 
 Cardinal for 123000000456000000789: one hundred and twenty-three quintillion, four hundred and fifty-six billion, seven hundred and eighty-nine
 Ordinal  for 123000000456000000789: one hundred and twenty-three quintillion, four hundred and fifty-six billion, seven hundred and eighty-ninth
 Cardinal for 1000000000000000000000023: one septillion and twenty-three
 Ordinal  for 1000000000000000000000023: one septillion and twenty-third
 Cardinal for 2034500: two million, thirty-four thousand, five hundred
 Ordinal  for 2034500: two million, thirty-four thousand, five hundredth
 Cardinal for 975310000000000000000000000987654321: nine hundred and seventy-five times ten to the thirty-third, three hundred and ten nonillion, nine hundred and eighty-seven million, six hundred and fifty-four thousand, three hundred and twenty-one
 Ordinal  for 975310000000000000000000000987654321: nine hundred and seventy-five times ten to the thirty-third, three hundred and ten nonillion, nine hundred and eighty-seven million, six hundred and fifty-four thousand, three hundred and twenty-first
 Cardinal for 1000000000000000000000000000000000000: one times ten to the thirty-sixth
 Ordinal  for 1000000000000000000000000000000000000: one times ten to the thirty-sixthth

As noted in How can I convert a number to its English form in Perl? - Stack Overflow

Best wishes ... cheers, drl
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert ip address to ip number

I want to make a script to read a list of ip addresses from a file then convert those ip addresses to ip number. ip number is made by removing the dots then transfer to a number , so the ip number transfered to binary then to decimal which will represents the ip number 0 : 4294967295 Also I... (17 Replies)
Discussion started by: moutaz1983
17 Replies

2. Shell Programming and Scripting

How to convert English text file to ASCII File?

file abc abc: English text I want to convert the above into file abc file: ascii text (1 Reply)
Discussion started by: laknar
1 Replies

3. Shell Programming and Scripting

need script to convert number in hexadecimal

hi , i need a script to convert number into hexadecimal base for example: 237=>ED it s very important for me thank you in advance for you help (5 Replies)
Discussion started by: mips
5 Replies

4. Shell Programming and Scripting

Convert e+ to number

Hi, I am using awk to get particular dates in seconds and the output am getting is like 1.28071e+09. How can I convert it to number format. Can anyone help me out? Thanks in advance..! (7 Replies)
Discussion started by: Kattoor
7 Replies

5. Shell Programming and Scripting

convert english to chinese

Hi Experts, Can anyone help me to convert a english input into chinese in a bash script. help would be highly appreciable. thanks, Deepak (3 Replies)
Discussion started by: naw_deepak
3 Replies

6. Programming

SED - how do I convert a decimal number to asterisk

Hi, My animal ID's have two zeros in them and are also converting to asterisk. I only need to change the zero values in columns two and three. I would appreciate any help. This is my data structure: head phendata.txt 201008809 0.0 0.0 201008810 0.0 0.0 201008813 0.0 0.0 201014103... (6 Replies)
Discussion started by: lel7lel7
6 Replies

7. Shell Programming and Scripting

Convert number

friends as I can convert this value to number in this example it is well but can vary the value does not help me cut from a nesecito espefifica opsiocn get zero CantCabe = 00023 Cant = 23 CantPntCabe = 0000000000000034 CantPnt = 34 if && ; then echo... (3 Replies)
Discussion started by: tricampeon81
3 Replies

8. Shell Programming and Scripting

Convert string number to a integer

I have data as below "ROWS merge process complete. thousand rows changed" I need to get a variable assigned the value of 1000. I mean convert the string thousand to 1000. Any help or pointer. Please use CODE tags as required by forum rules! (6 Replies)
Discussion started by: dsravanam
6 Replies

9. Shell Programming and Scripting

Convert a String to a Number

I read in two numbers from a user but the number is a string. #!/bin/bash read -p "Enter first number: " num1 read -p "Enter second number: " num2 I know you can use the the "expr" or "bc" command to automatically convert the string to a number then add them together. But I don't want to add... (10 Replies)
Discussion started by: Loc
10 Replies

10. Shell Programming and Scripting

Convert floating point to a number

Hello Guys, I have a floating point number 1.14475E+15 I want to convert this number in to full number (Integer or Big integer). I tried couple of functions it did not work. When I use INT=${FLOAT/.*} I am getting value as 1. I don't want a truncated value #!/bin/bash #... (9 Replies)
Discussion started by: skatpally
9 Replies
dhcp_modules(5) 					Standards, Environments, and Macros					   dhcp_modules(5)

NAME
dhcp_modules - data storage modules for the DHCP service DESCRIPTION
This man page describes the characteristics of data storage modules (public modules) for use by the Solaris Dynamic Host Configuration Pro- tocol (DHCP) service. Public modules are the part of the DHCP service architecture that encapsulate the details of storing DHCP service data in a data storage service. Examples of data storage services are NIS+, Oracle, and ufs file systems. Public modules are dynamic objects which can be shipped separately from the Solaris DHCP service. Once installed, a public module is visi- ble to the DHCP service, and can be selected for use by the service through the DHCP service management interfaces (dhcpmgr(1M), dhcpcon- fig(1M), dhtadm(1M), and pntadm(1M)). Public modules may be provided by Sun Microsystems, Inc or by third parties. The Solaris DHCP service management architecture provides a mechanism for plugging in public module-specific administration functionality into the dhcpmgr(1M) and dhcpconfig(1M) utilities. This functionality is in the form of a Java Bean, which is provided by the public module vendor. This Java Bean collects public module-specific configuration from the user (you) and provides it to the Solaris DHCP service. The Solaris DHCP service bundles three modules with the service, which are described below. There are three dhcpsvc.conf(4) DHCP service configuration parameters pertaining to public modules: RESOURCE, PATH, and RESOURCE_CONFIG. See dhcpsvc.conf(4) for more information about these parameters. SUNWfiles This module stores its data in ASCII files. Although the format is ASCII, hand-editing is discouraged. It is useful for DHCP service envi- ronments that support several hundred to a couple thousand of clients and lease times are a few hours or more. This module's data may be shared between DHCP servers through the use of NFS. SUNWbinfiles This module stores its data in binary files. It is useful for DHCP service environments with many networks and many thousands of clients. This module provides an order of magnitude increase in performance and capacity over SUNWfiles. This module's data cannot be shared between DHCP servers. SUNWnisplus This module stores its data within a NIS+ domain. It is useful in environments where NIS+ is already deployed and facilitates sharing among multiple DHCP servers. This module suports several hundred to a few thousand clients with lease times of several hours or more. The NIS+ service should be hosted on a machine with ample CPU power, memory, and disk space, as the load on NIS+ is significant when it is used to store DHCP data. Periodic checkpointing of the NIS+ service is necessary in order to roll the transaction logs and keep the NIS+ service operating at its highest efficiency. See nisping(1M) and crontab(1) for more information. SEE ALSO
crontab(1), dhcpconfig(1M), dhcpmgr(1M), dhtadm(1M), nisping(1M), pntadm(1M), dhcpsvc.conf(4), dhcp(5) Solaris DHCP Service Developer's Guide SunOS 5.10 24 Jan 2003 dhcp_modules(5)
All times are GMT -4. The time now is 07:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy