[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] Re: Excluir linha de um arquivo usando grep ?
From: |
Arthur M. Meskelis |
Subject: |
Re: [shell-script] Re: Excluir linha de um arquivo usando grep ? |
Date: |
Wed, 5 Nov 2008 17:09:27 -0200 |
$ grep --version
grep (GNU grep) 2.5
Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
no manual...
-v, --invert-match
Invert the sense of matching, to select non-matching lines.
esse é o meu grep
2008/11/5 pythondeveloper <address@hidden>:
> Ola galera, realmente o meu comando grep deve ser diferente do de vcs,
> não é possivel, pq aqui o esquema não funciona de jeito nenhum.
>
> $cat arquivo.txt
> fernando
>
> $grep "fernando" -v arquivo.txt
>
> $cat arquivo.txt
> fernando
>
> Ou seja, não remove a linha fernando de jeito nenhum.
>
> Alguma idéia ?
>
> --- Em address@hidden, "Arthur M. Meskelis"
> <hallofriendlich@...> escreveu
>
>>
>> $ cat teste
>> arthur
>> pedro
>> bruno
>> ricardo
>>
>> $ grep arthur -v teste
>> pedro
>> bruno
>> ricardo
>>
>> pode ser a palavra que você esta tentando remover do arquivo, pois
>> neste teste simples funciona
>>
>> 2008/11/5 pythondeveloper <pythondeveloper@...>:
>> > Galera
>> >
>> > Estou tentando da maneira como me instruiram mas sem sucesso...
>> >
>> > Vejam.
>> > $grep -v ".site.com.br" arquivo.txt > deletados.txt
>> >
>> > Ele está criando o arquivo deletados.txt com todas as informações de
>> > arquivo.txt e não esta removendo a linha ".site.com.br" de arquivo.txt
>> >
>> > Alguma ideia ?
>> >
>> > --- Em address@hidden, "Cléoson Barreto"
>> > <cleoson.barreto@> escreveu
>> >
>> >>
>> >> Olá!
>> >>
>> >> Se voce fizer:
>> >>
>> >> $ grep -v "frase do dia" arquivo.txt > novo_arquivo.txt
>> >>
>> >> vai funcionar. Mas eu acho que seria melhor usar o sed pra fazer
>> > isso:
>> >>
>> >> $ sed -i.old '/frase do dia/d' arquivo.txt
>> >>
>> >> Assim, você salva uma cópia do arquivo com a extensão .old, e
>> > vai
>> >> apagar todas as linhas que contiverema string "frase do dia".
>> >>
>> >> []'s
>> >> Cléoson.
>> >>
>> >>
>> >> 2008/11/5 pythondeveloper <pythondeveloper@>
>> >>
>> >> > Saudações...
>> >> >
>> >> > Preciso de uma solução para excluir uma linha de um arquivo.txt,
>> > li que
>> >> > o comando grep com a opção -v faz isso, mas não estou conseguindo
>> > fazer.
>> >> >
>> >> > Estou tentando assim.
>> >> > $grep -v "frase do dia" arquivo.txt
>> >> >
>> >> > Ainda não tive solução, alguma idéia ?
>> >> >
>> >> > Obrigado
>> >> >
>> >>
>> >>
>> >> [As partes desta mensagem que não continham texto foram removidas]
>> >>
>> >
>> >
>>
>
>