![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| the amount of memory consumed per user | big123456 | UNIX for Advanced & Expert Users | 1 | 11-24-2006 05:22 AM |
| amount of memory in my server | new2ss | UNIX for Dummies Questions & Answers | 2 | 11-06-2006 10:28 AM |
| sed X amount of times - X is dynamic | Loriel | Shell Programming and Scripting | 2 | 02-17-2005 08:38 PM |
| Amount of RAM (Memory) | samudimu | UNIX for Dummies Questions & Answers | 4 | 07-29-2003 02:40 PM |
| How to get amount of memory installed. | elgholm | UNIX for Dummies Questions & Answers | 4 | 08-24-2001 08:04 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
reply amount to another format
hello,
i have a txt file called a.txt with million of records...I would like to change amount field (last two field)..if it displayed ".00" changed to "0.00" and displayed ".51" changed to "0.51" example of a.txt RECORD ID,CLIENT,CUSTOMER NAME,2883,12:05,8, 16.39, 191.34 RECORD ID,CLIENT,CUSTOMER NAME,2879,00:00,0, .00, .00 RECORD ID,CLIENT,CUSTOMER NAME,2873,00:00,0, .00, .00 RECORD ID,CLIENT,CUSTOMER NAME,2871,00:00,0, .00, .00 RECORD ID,CLIENT,CUSTOMER NAME,2865,00:00,0, .00, .00 RECORD ID,CLIENT,CUSTOMER NAME,2858,00:00,0, .00, .00 RECORD ID,CLIENT,CUSTOMER NAME,2876,00:00,0, .00, .00 RECORD ID,CLIENT,CUSTOMER NAME,2863,00:00,0, .00, .00 RECORD ID,CLIENT,CUSTOMER NAME,2868,00:00,0, .00, .00 RECORD ID,CLIENT,CUSTOMER NAME,2866,00:00,0, .00, .00 RECORD ID,CLIENT,CUSTOMER NAME,2864,00:00,0, .00, .00 RECORD ID,CLIENT,CUSTOMER NAME,2882,07:65, 11, 13.77, 160.80 RECORD ID,CLIENT,CUSTOMER NAME,2880,01:72,2,5.63, 65.76 RECORD ID,CLIENT,CUSTOMER NAME,2877,00:00, 18,4.63, 54.00 RECORD ID,CLIENT,CUSTOMER NAME,2874,00:00,2, .51,6.00 RECORD ID,CLIENT,CUSTOMER NAME,2870,01:65,1, .39,4.60 Last edited by happyv; 03-12-2007 at 10:28 PM.. |
|
||||
|
Quote:
|
|
|||||
|
Using awk
Code:
$ awk -F"," '{gsub(/ .00/,"0.00",$0);gsub(/ \./,"0.",$0);print $0}' tmp.txt
RECORD ID,CLIENT,CUSTOMER NAME,2883,12:05,8, 16.39, 191.34
RECORD ID,CLIENT,CUSTOMER NAME,2879,00:00,0,0.00,0.00
RECORD ID,CLIENT,CUSTOMER NAME,2873,00:00,0,0.00,0.00
RECORD ID,CLIENT,CUSTOMER NAME,2871,00:00,0,0.00,0.00
RECORD ID,CLIENT,CUSTOMER NAME,2865,00:00,0,0.00,0.00
RECORD ID,CLIENT,CUSTOMER NAME,2858,00:00,0,0.00,0.00
RECORD ID,CLIENT,CUSTOMER NAME,2876,00:00,0,0.00,0.00
RECORD ID,CLIENT,CUSTOMER NAME,2863,00:00,0,0.00,0.00
RECORD ID,CLIENT,CUSTOMER NAME,2868,00:00,0,0.00,0.00
RECORD ID,CLIENT,CUSTOMER NAME,2866,00:00,0,0.00,0.00
RECORD ID,CLIENT,CUSTOMER NAME,2864,00:00,0,0.00,0.00
RECORD ID,CLIENT,CUSTOMER NAME,2882,07:65, 11, 13.77, 160.80
RECORD ID,CLIENT,CUSTOMER NAME,2880,01:72,2,5.63, 65.76
RECORD ID,CLIENT,CUSTOMER NAME,2877,00:00, 18,4.63, 54.00
RECORD ID,CLIENT,CUSTOMER NAME,2874,00:00,2,0.51,6.00
RECORD ID,CLIENT,CUSTOMER NAME,2870,01:65,1,0.39,4.60
$
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|