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
What the command to find out the record length of a fixed length file? tranq01 UNIX for Dummies Questions & Answers 9 12-04-2008 04:04 PM
convert fixed length file to CSV tbtbs Shell Programming and Scripting 12 08-12-2008 09:54 AM
how to convert Fixed length file to delimited file. satyam_sat Shell Programming and Scripting 7 04-03-2008 02:41 AM
convert XML file into Text file(fixed length) ram2s2001 Shell Programming and Scripting 0 11-03-2005 01:28 AM
Convert delimited to fixed length nelson553011 Shell Programming and Scripting 14 10-27-2005 04:04 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 12-18-2008
Everton_Silveir Everton_Silveir is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 1
Convert a tab delimited/variable length file to fixed length file

Hi, all.

I need to convert a file tab delimited/variable length file in AIX to a fixed lenght file delimited by spaces. This is the input file:

10200002<tab>US$ COM<tab>16/12/2008<tab>2,3775<tab>2,3783
19300978<tab>EURO<tab>16/12/2008<tab>3,28523<tab>3,28657


And this is the expected output:

10200002 US$ COM 16/12/2008 2,3775 2,3783 <<17 SPACES>>
19300978 EURO 16/12/2008 3,28523 3,28657<<17 SPACES>>

Thanks,

Everton Silveira
  #2 (permalink)  
Old 12-19-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
Code:
while read LINE; do
   printf "%s                 \n" "`echo "$LINE"| tr -s '\t' ' '`"
done < infile > outfile
Check the spaces inside vi with ":set list" maybe.
  #3 (permalink)  
Old 12-19-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
Another approach:

Code:
awk '{$(NF+17)=""}1' file > outfile
Regards

Last edited by Franklin52; 12-19-2008 at 06:29 PM.. Reason: typo
Sponsored Links
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 01:11 AM.


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