|
Home > Archive > Unix Shell > March 2006 > Formatting Table
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| 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
| |
| Chris F.A. Johnson 2006-03-17, 5: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
| |
| Janis Papanagnou 2006-03-17, 5: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
|
|
|
|
|