Sponsored Content
Top Forums Shell Programming and Scripting Need to change format of number Post 302352747 by Franklin52 on Sunday 13th of September 2009 07:52:22 AM
Old 09-13-2009
How about this one:

Code:
awk -F, 'BEGIN{fmt="%\047.2f"} {
  printf(fmt":"fmt":"fmt"\n",$1,$2,$3)
}' file

This is my output:

Code:
$ cat file
12345.67,5678990.89,76232882.90
12345,5678990.89,76232882
$
$ awk -F, 'BEGIN{fmt="%\047.2f"} {
  printf(fmt":"fmt":"fmt"\n",$1,$2,$3)
}' file
12,345.67:5,678,990.89:76,232,882.90
12,345.00:5,678,990.89:76,232,882.00
$

Regards
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

change the empty function from the old format to the new format

I have about 300 files which has the function getDBBackend(). How to write a program to change the empty function from the old format to the new format? Old empty function format are either: function getDBBackend() { // Not available } // getDBBackend or: function... (0 Replies)
Discussion started by: powah
0 Replies

2. UNIX for Dummies Questions & Answers

How to change it to the date format

Hi, I want to know how to change this string to date format 20061102122042 to 02-11-2006 12:20:42 or 02-Nov-2006 12:20:42 Please let me know at the earliest.Thanks in advance. Regards, Preetham R. (3 Replies)
Discussion started by: preethgideon
3 Replies

3. UNIX for Advanced & Expert Users

Change date format

I know the command date +"%Y%m%d" can change today's date to digit format as below . $date +"%Y%m%d" 20071217 it works fine . now I want to do it back . If I have a file like below, (in the file , there are three lines, and each line have ; sign , after the ; sign is the date ) , I... (4 Replies)
Discussion started by: ust
4 Replies

4. Shell Programming and Scripting

Change of date format

I want to chnage the date format from the file format like below to WT;T15D;0000007208;;20080401;3;0;0;3;;B;ZZZZZZ; WT;T25D;0000007208;;20080401;6;0;0;6;;B;ZZZZZZ; WT;T5D;0000007208;;20080401;123;0;0;123;;B;ZZZZZZ; to WT;T15D;0000007208;;04/01/200804;3;0;0;3;;B;ZZZZZZ;... (2 Replies)
Discussion started by: svenkatareddy
2 Replies

5. Shell Programming and Scripting

Change date format

Hi guys, I have a text file with lots of lines like this: MCOGT23R27815 27/07/07 27/05/09 SO733AM0235 30/11/07 30/11/10 NL123403N 04/03/08 04/03/11 0747AM7474 04/04/08 04/04/11 I want to change each line so the date format looks like this: MCOGT23R27815 07/07/27 09/05/27 ... (7 Replies)
Discussion started by: Tornado
7 Replies

6. Shell Programming and Scripting

format change

I have a text file sample.txt which contains some details like Order 9001 Item Code 34 Quantity 4 Entry Date 2009-04-23 Ordered by Ram Order 9002 Item Code 34 Quantity 3 (1 Reply)
Discussion started by: lazydev
1 Replies

7. Shell Programming and Scripting

Date Format Change

Hi, Please can I have some command to get yesterday in YYMMDD format? This will be used in ksh Thanks, (2 Replies)
Discussion started by: smalya
2 Replies

8. Shell Programming and Scripting

Change Date Format

Hi Guys, I had a scenario like this.. It seems very silly...dont think it as a home work question.....:) i tried it many ways but i didn't achieve this... start_date=May122011 here i want to change the start_date in to 20110512 start_date=20110512 tell me how can we achive... (5 Replies)
Discussion started by: apple2685
5 Replies

9. Shell Programming and Scripting

Format change

I wish to convert the following in shell. Help me SED or AWK ID= 12345,23456,67859 , 90225 , 67583 I can extract the right hand side of "=" using cut command "cut -d "=" -f2 after extracting that right side i would need like this '12345','23456','67859','90225','67583' 1 ) the... (2 Replies)
Discussion started by: ilugopal
2 Replies

10. Shell Programming and Scripting

Change name format

I am trying to use either awk or sed to make names like J. A. Smith and J.A. Martin Smith become JA Smith and JA Martin SmithThe code should concatenate abbreviated letters that have a dot after them. I have only been able to do this: echo $name | sed 's/\.\ //g'But that concatenates the... (3 Replies)
Discussion started by: locoroco
3 Replies
NUMFMT_GET_ERROR_MESSAGE(3)						 1					       NUMFMT_GET_ERROR_MESSAGE(3)

NumberFormatter::getErrorMessage - Get formatter's last error message.

	Object oriented style

SYNOPSIS
public string NumberFormatter::getErrorMessage (void ) DESCRIPTION
Procedural style string numfmt_get_error_message (NumberFormatter $fmt) Get error message from the last function performed by the formatter. PARAMETERS
o $fmt -NumberFormatter object. RETURN VALUES
Returns error message from last formatter call. EXAMPLES
Example #1 numfmt_get_error_message(3) example <?php $fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL ); $data = numfmt_format($fmt, 1234567.891234567890000); if(intl_is_failure(numfmt_get_error_code($fmt))) { report_error("Formatter error"); } ?> Example #2 OO example <?php $fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL ); $fmt->format(1234567.891234567890000); if(intl_is_failure($fmt->getErrorCode())) { report_error("Formatter error"); } ?> SEE ALSO
numfmt_get_error_code(3), intl_get_error_code(3), intl_is_failure(3). PHP Documentation Group NUMFMT_GET_ERROR_MESSAGE(3)
All times are GMT -4. The time now is 07:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy