Reorganize o filecontent no UNIX

1

Eu preciso reorganizar isso:

 ----------------------------------------------------------------
 - Partition Name: testblade012                                 -
 - Type: Shared-SMT-4                                           -
 - Entitled Capacity: 0.30                                      -
 ----------------------------------------------------------------

para isso:

 ----------------------------------------------------------------
 - Partition Name                           : testblade012      -
 - Type                                     : Shared-SMT-4      -
 - Entitled Capacity                        : 0.30              -  
 ----------------------------------------------------------------
    
por Sivas 12.09.2015 / 15:09

1 resposta

2

Apenas printf :

while IFS=[:] read f1 f2
do
    [ "$f2" ] && printf '%-40s: %-22s-\n' "$f1" "$(echo ${f2%-})" || echo "$f1"
done <<<' ----------------------------------------------------------------
 - Partition Name: testblade012                                 -
 - Type: Shared-SMT-4                                           -
 - Entitled Capacity: 0.30                                      -
 ----------------------------------------------------------------'

Ou com awk

awk -F'[:]' '$2{sub(" *-$","",$2);$0=sprintf("%-40s:%-23s-",$1,$2)}1'
    
por 12.09.2015 / 16:19