The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
reformat date, awk and sed mondrar Shell Programming and Scripting 5 06-05-2008 04:08 PM
help reformat data with awk climbak Shell Programming and Scripting 4 05-30-2008 03:17 PM
Reformat Crontab file alnita Shell Programming and Scripting 1 04-11-2007 03:28 AM
Date Reformat F-1 UNIX for Dummies Questions & Answers 2 04-25-2006 04:32 PM
how to reformat a file to 80 byte rec length? cmgarcia Shell Programming and Scripting 4 04-25-2006 11:44 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-08-2005
CamTu CamTu is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 46
reformat the file

Hi all,

I ran into this problem, hope you can help

I have a text file like this:
Code:
Spriden ID  First Name       Last Name                                                     Term Code  Detail Code                   Amount  Trans Date               Description                     
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 000702986   Yukiko           Adachi                                                        200520     EASY                           20.00  2005-03-07 12:00AM       SCAD Debit Card Charge        
000723223   Casey            Jothen                                                        200530     EASY                          600.00  2005-03-08 12:00AM       SCAD Debit Card Charge
and when i run the awk program to format the file, i got this result:
Code:
V2
U000634426          Kwok, Celine                           01/01/10                                                                                                                          SCAD Group Inc.                                                                                                                                                                   PA01001000100100PA01011010101101AD0100100240.0000
U000722952          Moore, John                            01/01/10                                                                                                                          SCAD Group Inc.                                                                                                                                                                   PA01001000100100PA01011010101101AD0100100300.0000
Is there a way I can get rid of the ".00" (those that I have in bold font) from the dollar amount and have the result like this instead:
Code:
V2
U000634426          Kwok, Celine                           01/01/10                                                                                                                          SCAD Group Inc.                                                                                                                                                                   PA01001000100100PA01011010101101AD010010024000
U000722952          Moore, John                            01/01/10                                                                                                                          SCAD Group Inc.                                                                                                                                                                   PA01001000100100PA01011010101101AD010010030000
Here is my awk program:
Code:
FNR==1{print "V2"} 
$6 > 0 && (( $9 $10 $(NF-1) $(NF) ) == "SCADDebitCardCharge" ) {
  _i=$3 ", " $2; _x=$6 "00"; printf("U%-19s%-39s%-130s%-178s%-41s%-6s\n", $1, _i, "01/01/10", "SCAD Group Inc.", "PA01001000100100PA01011010101101AD0100100", _x)
}
Thanks for any helps

CT
 

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 07:14 AM.


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