![]() |
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 Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| c program to extract text between two delimiters from some text file | kukretiabhi13 | High Level Programming | 7 | 12-03-2008 06:29 PM |
| align several fields and fill spaces with zero | DebianJ | Shell Programming and Scripting | 2 | 11-23-2005 07:51 AM |
| how to align report headers in awk | galinaqt | Shell Programming and Scripting | 3 | 10-16-2005 03:41 PM |
| How to underline/bold and how to align output | clara | UNIX for Dummies Questions & Answers | 1 | 06-16-2005 12:41 PM |
| grep multiple text files in folder into 1 text file? | coppertone | UNIX for Dummies Questions & Answers | 7 | 08-23-2002 02:50 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I need to align text from a file that has columns seperated by spaces and commas. Any ideas?
Text is similar to this. File Name is Test. 05/14/06 13:46:56.575 ,TEST,5,123,1234,123,12345,12,12.2,2.1,4.5,5.23 05/14/06 13:49:58.009 ,TEST,6,456,456.7,45,4.56,453,34,54.3,3.2,6.456 |
|
||||
|
I need to align text from a file that has columns seperated by spaces and commas. Any ideas?
Text is similar to this. File Name is Test. 05/14/06 13:46:56.575 ,TEST,5,123,1234,123,12345,12,12.2,2.1,4.5,5.23 05/14/06 13:49:58.009 ,TEST,6,456,456.7,45,4.56,453,34,54.3,3.2,6.456 |
|
||||
|
Here is the desire output
05/14/06 13:46:56.575 TEST 5 123 1234 123 12345 12 12.2 2.1 4.5 5.23 05/14/06 13:49:58.009 TEST 6 456 456.7 45 4.56 453 34 54.3 3.2 6.456 Doesn't look right in this Forum Field. Basically ##### ###### ### #### ### #### #### ##### ##### ###### ### #### ### #### #### ##### Last edited by earlepps; 07-31-2006 at 02:53 PM.. |
|
||||
|
awk can be used for this:
Code:
print "05/14/06 13:46:56.575 ,TEST,5,123,1234,123,12345,12,12.2,2.1,4.5,5.23
05/14/06 13:49:58.009 ,TEST,6,456,456.7,45,4.56,453,34,54.3,3.2,6.456" |
nawk -F, '
{ printf ("%-20s %-10s %-3d %12.2f %12.2f %12.2f %12.2f %12.2f %12.2f %12.2f %12.2f %12.2f \n", $1, $2, $3, $4, $5, $6 $7, $8, $9, $10, $11, $12, $13, $14) }
'
05/14/06 13:46:56.575 TEST 5 123.00 1234.00 12312345.00 12.00 12.20 2.10 4.50 5.23 0.00
05/14/06 13:49:58.009 TEST 6 456.00 456.70 454.56 453.00 34.00 54.30 3.20 6.46 0.00
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|