Unix/Linux Go Back    


UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

Arranging columns in a line

UNIX for Dummies Questions & Answers


 
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-08-2013
satyar satyar is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 24 January 2013, 9:15 AM EST
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
Arranging columns in a line

Hi,
Please give a solution...

Current File


Code:
200101701    A    5    B    283    D    222
200085506    A    5    B    6    C    304
200081406    A    5                    
200101784    D    1111

Desired Output


Code:
200101701    A    0005    B    0283    *    *    D    222    
200085506    A    0005    B    0006    C    0304    *    *
200081406    A    0005    *    *    *    *    *    *
200101784    *    *    *    *    *    *    D    1111

Sorry for formating related issues...

Thank

Last edited by Scrutinizer; 01-08-2013 at 03:54 AM.. Reason: removed img def
Sponsored Links
    #2  
Old Unix and Linux 01-08-2013
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is online now Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 9 December 2016, 4:32 AM EST
Location: Amsterdam
Posts: 11,106
Thanks: 440
Thanked 3,111 Times in 2,751 Posts
What have you tried so far?
Sponsored Links
    #3  
Old Unix and Linux 01-08-2013
satyar satyar is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 24 January 2013, 9:15 AM EST
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
I am trying to solve using awk...
    #4  
Old Unix and Linux 01-08-2013
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is online now Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 9 December 2016, 4:32 AM EST
Location: Amsterdam
Posts: 11,106
Thanks: 440
Thanked 3,111 Times in 2,751 Posts
What did you try while using awk?
Sponsored Links
    #5  
Old Unix and Linux 01-09-2013
rdrtx1 rdrtx1 is offline
Registered User
 
Join Date: Sep 2012
Last Activity: 7 December 2016, 9:36 PM EST
Location: Houston, Texas, USA
Posts: 873
Thanks: 0
Thanked 299 Times in 286 Posts
try:

Code:
awk '
BEGIN {str="ABCD"; l=length(str)*2}
{for (i=3; i<=NF; i+=2) $i=sprintf("%04d", $i);
 for (i=2; i<=l; i+=2) {
   j=index(str,$i);
   for (m=i/2; m<j; m++) { $i="*" OFS "*" OFS $i; $0=$0; }
 }
 for (i=(NF-1)/2; i<l/2; i++) { $(NF+i)="*" OFS "*"; }
 $0=$0;
}
$1=$1
' OFS="\t" infile

Sponsored Links
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need Help in arranging the output Sudeep Bhattad Shell Programming and Scripting 4 10-25-2012 04:21 AM
Arranging data bobo UNIX for Dummies Questions & Answers 3 01-20-2012 03:15 PM
arranging columns with AWK sramirez Shell Programming and Scripting 2 12-12-2010 03:06 PM
Averaging 100 columns together line by line jenjen_mt UNIX for Dummies Questions & Answers 2 08-03-2010 02:31 PM
need help in arranging the alias upengan78 Shell Programming and Scripting 4 07-09-2010 05:29 PM



All times are GMT -4. The time now is 05:35 AM.