[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] Re: Remover caracter do texto
From: |
Humberto Pereira |
Subject: |
Re: [shell-script] Re: Remover caracter do texto |
Date: |
Wed, 14 Dec 2005 14:00:10 -0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050923 Debian/1.7.12-0ubuntu05.04 |
Caro,
em /,$/ ele tenta casar uma linha q finalize com ','
qdo isso acontece ele habilita o multiline pattern space (N;)
e tenta casar com
',
);'
se casar, ele remove a ','.
O problema eh q ele soh pega qdo tem numeros impares de ',', pq qdo vc
usa o N;, ele vai pra proxima linha, e a proxima linha pode ser outra ','.
Acho q o melhor nesse caso eh usar awk (adoro ele :)).
awk ' $0 ~ /\);/ {
sub(/, *$/, "", nextLine)
}
{
if(nextLine)
print nextLine;
nextLine = $0
}
END {
print nextLine
} ' arquivo.sql
[]s
Humberto Pereira
weberlf wrote:
>> sed '/,$/ {
>> N;
>> s/,\n *);/\n);/
>> }'
>
>
> Humberto
>
> No exemplo abaixo que enviei funcionou beleza.
>
>
>>>CREATE TABLE tmor_1212_cred_agreg (
>>> seq_ctrc integer NOT NULL,
>>> tp_credito character(1) NOT NULL,
>>> placa_agreg character(7) NOT NULL,
>>> data_baixa date NOT NULL,
>>> vlr_credito numeric(9,2) NOT NULL,
>>> seq_ficha_frete integer NOT NULL,
>>> vlr_credito_orig numeric(9,2) NOT NULL,
>>> data_inclusao date,
>>> hora_inclusao time without time zone,
>>>);
>>>
>
>
> Mas neste exemplo abaixo nao funcionou
>
> CREATE TABLE tmor_1412_custo_exprec (
> cod_emp smallint NOT NULL,
> cod_fil smallint NOT NULL,
> seq_ctrc integer NOT NULL,
> fg_tipo character(1) NOT NULL,
> vlr_icms numeric(8,2) NOT NULL,
> vlr_cofins numeric(8,2) NOT NULL,
> vlr_pedagio numeric(8,2) NOT NULL,
> vlr_transf numeric(8,2) NOT NULL,
> vlr_transb numeric(8,2) NOT NULL,
> vlr_recepcao numeric(8,2) NOT NULL,
> perc_comi numeric(4,2) NOT NULL,
> data_inclusao date,
> vlr_peso numeric(8,2) NOT NULL,
> vlr_min numeric(8,2) NOT NULL,
> );
>
> Não querendo abusar, poderia me explicar o comando
> utilizado no primeiro caso ?
>
> Weber
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> Esta lista não admite a abordagem de outras liguagens de programação, como
> perl, C etc. Quem insistir em não seguir esta regra será moderado sem prévio
> aviso.
> ---------------------------------------------------------------------
> Sair da lista: address@hidden
> ---------------------------------------------------------------------
> Esta lista é moderada de acordo com o previsto em
> http://www.listas-discussao.cjb.net
> ---------------------------------------------------------------------
>
> Links do Yahoo! Grupos
>
>
>
>
>
>
>
>
- Remover caracter do texto, weberlf, 2005/12/12
- Re: [shell-script] Remover caracter do texto, Tiago Barcellos Peczenyj, 2005/12/12
- Re: Remover caracter do texto, weberlf, 2005/12/12
- Re: [shell-script] Re: Remover caracter do texto, Tiago Barcellos Peczenyj, 2005/12/12
- Re: [shell-script] Re: Remover caracter do texto, Humberto Pereira, 2005/12/13
- Re: Remover caracter do texto, weberlf, 2005/12/14
- Re: [shell-script] Re: Remover caracter do texto,
Humberto Pereira <=
- Re: Remover caracter do texto, weberlf, 2005/12/14
- Re: [shell-script] Re: Remover caracter do texto, Fabricio Lopes de Souza, 2005/12/16
Re: [shell-script] Remover caracter do texto, Humberto Pereira, 2005/12/12