![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Fill the Key fields : Please help us | charandevu | Shell Programming and Scripting | 11 | 04-08-2008 06:40 AM |
| Find fields with no spaces in value | alfredo123 | UNIX for Dummies Questions & Answers | 10 | 04-18-2007 03:14 PM |
| How can i remove spaces in between the fields in a file | dsravan | Shell Programming and Scripting | 3 | 09-26-2006 01:11 PM |
| Align Text from a file. | earlepps | UNIX for Dummies Questions & Answers | 9 | 08-01-2006 05:37 AM |
| Delete spaces in between fields | guiguy | Shell Programming and Scripting | 12 | 03-31-2006 06:38 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
align several fields and fill spaces with zero
hi all,
i have a big problem, and i donīt know what to do. i have a flat file with several fields, which are separated by ";" like this: 5656838-7B;97030000-7;*;V16106133 ;1;1; 4612062-0B;97030000-7;*;C14038149 ;1;2; 8044938-0B;97030000-7;*;V16034219 ;1;2; where B is a blank space. each line is a record, and all have the same length. and each field has its determinated length. Example: field1[10],field2[10],field3[1], field4[1],field5[8], ... what i need, is align the content of the field 1 and 2 to the rigth, and put a zero to its left, like this: 05656838-7;97030000-7;*;V16106133 ;1;1; 04612062-0;97030000-7;*;C14038149 ;1;2; 08044938-0;97030000-7;*;V16034219 ;1;2; is that possible?? please, any idea thanks |
| Forum Sponsor | ||
|
|
|
#3
|
|||
|
|||
|
Another way:
cut -c1-9 filename >temp1 cut -c11- filename>temp2 paste -d"\0" temp1 temp2|sed 's/^/0/g' |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|