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

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

Dica do Ivan - fazer barras horizontais de tamanho especifico usando sed


From: Ivan lopes
Subject: Dica do Ivan - fazer barras horizontais de tamanho especifico usando sed
Date: Sat, 7 Jun 2008 15:32:54 -0300

objetivo:
uma barra de tamanho 10 compasta pelo caracter '=' igual
=========
0123456789


algoritmo:
========

label :__begin__

if strlen(linha) == 10
   print linha
   then goto __end__
endif

linha = linha + '='

goto __begin__


em sed:
==========
$ echo | sed ':begin;
                          s/^.\{10\}$/&/;
                          tend;

                    s/$/=/;
                    tbegin;

                    :end'


ou inline:
$ echo a | sed ':begin;s/^.\{10\}$/&/;tend;s/$/=/;tbegin;:end'



-- 
[]'s
Ivan Carlos da Silva Lopes
Engenheiro Eletrônico e de Computação
blog --> http://lopesivan.blogspot.com/


reply via email to

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