![]() |
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 |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help me clean this up | scanner248 | UNIX for Dummies Questions & Answers | 1 | 10-15-2007 04:31 PM |
| Clean Text File | kris01752 | UNIX for Advanced & Expert Users | 1 | 08-24-2006 02:48 PM |
| Clean file in single action | djp | Shell Programming and Scripting | 1 | 06-19-2006 05:34 PM |
| /tmp clean up at reboot | Silver11 | SUN Solaris | 2 | 03-07-2006 01:08 AM |
| Clean an LV out of the ODM | Wamland | UNIX for Advanced & Expert Users | 0 | 11-23-2004 04:44 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Clean File
BeginDate 07/01/06
End: 07/31/06 Cust: A02991 - Burnham 0002000 5,829,773 145.3 0009701 4,043,850 267.3 2005000 286,785.13 100.0 BeginDate 07/01/06 End: 07/31/06 Cust: A01239 - East Track PSE Index A 0009902 317,356.82 890.2 0020021 94,694.23 90989.1 BeginDate 07/01/06 End: 07/31/06 Cust: A04067 - Fidelity Growth investement 0009902 1,063,852 2990.3 0020021 699,709.35 4590.3 Above is my incoming file format. I need to create a file with 6 columns( BeginDate,EndDate,Cust and the three associated columns with each Customer).The customer record some times may be shown as 2 records.I need to make as one record. I am kind of lost how to solve |
|
||||
|
Begin End Cust: Col1 Col2 Col3
07/01/06 07/31/06 A02991 - Burnham 0002000 5,829,773 145.3 07/01/06 07/31/06 A02991 - Burnham 0009701 4,043,850 267.3 07/01/06 07/31/06 A02991 - Burnham 2005000 286,785.13 100.0 This is how i need the output. |
|
||||
|
Code:
awk '
/BeginDate/ {
getline end_dt
getline cust
getline cust1
sub(".* ","",$0)
bgn_dt=$0
sub(".*: ","",end_dt)
sub(".*: ","",cust)
if ( match ( cust1 , "^[0-9][0-9]*" ) )
print $0 " " end_dt " " cust " " cust1
else
{
cust = cust cust1
}
}
/^[0-9]+/{
print bgn_dt " " end_dt " " cust " " $0 }' file
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|