Formatting Table
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Shell > Formatting Table




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Formatting Table  
Sal


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-17-06 10:54 PM

Hi all,

I have the following table



DesiredCPU  DesiredMEM  MaxCPU  MaxMEM  MinCPU  MinMEM
2                  6144              4              6144         1
3072
2                  6144              4              6144         1
3072

What I need is to have first

MinCPU   Desired CPU  MaxCPU   MinMEM  DesiredMEM MaxMEM


Any advice how to do it.

Regards






[ Post a follow-up to this message ]



    Re: Formatting Table  
Chris F.A. Johnson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-17-06 10:54 PM

On 2006-03-17, Sal wrote:
> Hi all,
>
> I have the following table
>
>
>
> DesiredCPU  DesiredMEM  MaxCPU  MaxMEM  MinCPU  MinMEM
> 2            6144        4              6144         1       3072
> 2            6144        4              6144         1       3072
>
> What I need is to have first
>
> MinCPU   Desired CPU  MaxCPU   MinMEM  DesiredMEM MaxMEM

awk '{printf "%s\t%s\t%s\t%s\t%s\t%s\n", $5, $1, $3, $6, $2, $4}'

--
Chris F.A. Johnson, author   |    <http://cfaj.freeshell.org>
Shell Scripting Recipes:     |  My code in this post, if any,
A Problem-Solution Approach  |          is released under the
2005, Apress                 |     GNU General Public Licence





[ Post a follow-up to this message ]



    Re: Formatting Table  
Janis Papanagnou


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-17-06 10:54 PM

Sal wrote:
> Hi all,
>
> I have the following table
>
>
>
> DesiredCPU  DesiredMEM  MaxCPU  MaxMEM  MinCPU  MinMEM
> 2                  6144              4              6144         1
>       3072
> 2                  6144              4              6144         1
>       3072
>
> What I need is to have first
>
> MinCPU   Desired CPU  MaxCPU   MinMEM  DesiredMEM MaxMEM
>
>
> Any advice how to do it.
>
> Regards
>

Simplest sulution is output separated by spaces...

awk '{print $5,$1,$3,$6,$2,$4}'

or optionally specify some fixed output field separator (OFS)

awk 'BEGIN{OFS="\t"}{print $5,$1,$3,$6,$2,$4}'

or if you want individually formatted column widths, e.g.

awk '{printf("%16s%12s%12s%15s%10s%12s\n",$5,$1,$3,$6,$2,$4)}'


Janis





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 02:20 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register