[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] Inserir string no inicio da linha
From: |
Andreyev Dia de Melo |
Subject: |
Re: [shell-script] Inserir string no inicio da linha |
Date: |
Tue, 10 Sep 2002 17:16:18 -0300 |
User-agent: |
Mutt/1.3.17i |
Hehe!!
Desculpem-me...
O correto seria usar o "head -1" para ter a 1a ocorrencia...
cat <arquivo> | sed -e '`grep -n <string> <arquivo> | cut -f 1 -d : | head -1`
s/^/novo texto/' >arquivo_novo.txt
tac <arquivo> | sed -e '`grep -n <string> <arquivo> | cut -f 1 -d : | head -1`
s/^/novo texto/' >arquivo_novo.txt
Combinando o "head" e o "tail" vc poderia buscar a enesima ocorrencia, por
exemplo:
cat <arquivo> | sed -e '`grep -n <string> <arquivo> | cut -f 1 -d : | head -n |
tail -1` s/^/novo texto/' >arquivo_novo.txt
Mas isso nao seria MT util...
Obrigado pela correcao, e mais uma vez desculpem-me...
--
--------------------------------------
Andreyev Dias de Melo
CPqD Telecom & IT Solutions
Gerência de Infraestrutura e Produção
Fone.: + 55 19 3705-6917
Fax : + 55 19 3705-6113
Cel. : + 55 19 9116-4539
e-mail: address@hidden
http://www.cpqd.com.br