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

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

Re: [shell-script] Alteracao de variavel em varios arquivos


From: Herbert Alexander Faleiros
Subject: Re: [shell-script] Alteracao de variavel em varios arquivos
Date: Mon, 24 Jul 2006 19:28:25 -0300
User-agent: KMail/1.9.3

On Monday 24 July 2006 19:15, Leandro Costa wrote:
[cut]
> trocar a variavel host=antigo para host=novo de todos os arquivo

Olá,

isso dá p/ resolver com o sed:

$ cat *.php
host=xxx
host=xxx
host=xxx

Só por segurança, não sobrescreva os arquivos (ainda)...

$ for i in *.php; do cat $i | sed 's/host=xxx/host=yyy/g' > $i.tmp; done

$ cat *.tmp
host=yyy
host=yyy
host=yyy

Se deu certo, substitua o laço acima por:

$ for i in *.php; do sed -ri 's/(host=)yyy/\1xxx/g' $i; done

$ cat *.php
host=yyy
host=yyy
host=yyy


Até,

Herbert.


reply via email to

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