Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing name

Status
Not open for further replies.

ng1

Technical User
Aug 22, 2007
39
US
I have a file that looks like this:

1111 51 09/26/07 100.00
09/21/07 1001.92
09/06/07 645.00
09/05/07 2774.75
TOTALS 4 4521.67
2222 50 09/28/07 750.00
09/14/07 500.00
09/13/07 3000.00
TOTALS 4 4392.00
3333 50 09/26/07 1220.00
09/05/07 1023.57
09/04/07 285.00
09/04/07 617.90
TOTALS 4 3146.47
Here is my desired output:


1111 51 09/26/07 100.00
1111 51 09/21/07 1001.92
1111 51 09/06/07 645.00
1111 51 09/05/07 2774.75
TOTALS 4 4521.67
2222 50 09/28/07 750.00
2222 50 09/14/07 500.00
2222 50 09/13/07 3000.00
TOTALS 4 4392.00
3333 50 09/26/07 1220.00
3333 50 09/05/07 1023.57
3333 50 09/04/07 285.00
3333 50 09/04/07 617.90
TOTALS 4 3146.47


How do I get there?

Thanks!
 
Code:
NF==4 { f1=$1; f2=$2 }
NF==2 { $1=f1 OFS f2 OFS $1 }
1

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Is there any way to keep the formatting the same?

It gives me the desired output, but it does not line up.
It gives me this:

1111 51 09/26/07 100.00
1111 51 09/21/07 1001.92
1111 51 09/06/07 645.00


Thanks.
 
Have a look at the printf function.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I got it with the printf function. Thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top