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 > UNIX for Dummies Questions & Answers
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-31-2006
earlepps earlepps is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 5
Question Align Text from a file.

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
  #2 (permalink)  
Old 07-31-2006
earlepps earlepps is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 5
Question Align Text from a file.

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
  #3 (permalink)  
Old 07-31-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
Be more specific. Provide what your desired output should look like
  #4 (permalink)  
Old 07-31-2006
earlepps earlepps is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 5
Arrow

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..
  #5 (permalink)  
Old 07-31-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
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
This should help you some.
  #6 (permalink)  
Old 07-31-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
earlepps - don't post in two places.
You got basically the same answer - twice - and wasted tmarikle's time.
  #7 (permalink)  
Old 08-01-2006
earlepps earlepps is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 5
Thanks for the help.
Closed Thread

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 08:13 PM.


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