shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bulk] Re: [shell-script] Preenchimento com espaços a esquerda


From: Sidney Souza
Subject: Re: [Bulk] Re: [shell-script] Preenchimento com espaços a esquerda
Date: Mon, 10 Aug 2015 14:28:09 -0300

Isso não resolve o seu problema:

awk '{printf("%10s%20s%15s\n", $2, $3, $1)}' origin.txt > destination.txt

origin.txt content
       123            cachorro          teste
       123            cachorro          teste
       123            cachorro          teste
       123            cachorro          teste
       123            cachorro          teste

destination.txt content
  cachorro               teste            123
  cachorro               teste            123
  cachorro               teste            123
  cachorro               teste            123
  cachorro               teste            123



------------------------------------------------------
http://www.politicos.org.br

2015-08-10 13:29 GMT-03:00 address@hidden [shell-script] <address@hidden>:
 

Sendo direto:

echo "       123            cachorro          teste" |
sed 's/\(.\{10\}\)\(.\{20\}\)\(.\{15\}\)/|\1|\2|\3/' |
awk -F '([|][ ]*)' '{printf "%10s%20s%15s\n", $3, $4, $2}'


e caso tenho um arquivo troque:
 echo "       123            cachorro          teste
por:
 cat arquivo.txt
 
Ou faça:
sed 's/\(.\{10\}\)\(.\{20\}\)\(.\{15\}\)/|\1|\2|\3/' arquivo.txt |
awk -F '([|][ ]*)' '{printf "%10s%20s%15s\n", $3, $4, $2}'


[]'s
Itamar



reply via email to

[Prev in Thread] Current Thread [Next in Thread]