The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Fill the Key fields : Please help us charandevu Shell Programming and Scripting 11 04-08-2008 10:40 AM
Find fields with no spaces in value alfredo123 UNIX for Dummies Questions & Answers 10 04-18-2007 07:14 PM
How can i remove spaces in between the fields in a file dsravan Shell Programming and Scripting 3 09-26-2006 05:11 PM
Align Text from a file. earlepps UNIX for Dummies Questions & Answers 9 08-01-2006 09:37 AM
Delete spaces in between fields guiguy Shell Programming and Scripting 12 03-31-2006 10:38 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-18-2005
DebianJ DebianJ is offline
Registered User
  
 

Join Date: May 2005
Posts: 52
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
  #2 (permalink)  
Old 11-19-2005
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
hasn't it already been answered here?

seems very similar to me......
  #3 (permalink)  
Old 11-23-2005
Abhishek Ghose Abhishek Ghose is offline
Registered User
  
 

Join Date: Sep 2005
Location: Chennai
Posts: 81
Another way:

cut -c1-9 filename >temp1
cut -c11- filename>temp2
paste -d"\0" temp1 temp2|sed 's/^/0/g'
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 12:27 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