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

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

RE: [shell-script] Substituições em série


From: MrBiTs
Subject: RE: [shell-script] Substituições em série
Date: Mon, 15 Aug 2005 11:41:41 -0300

/*
Preciso fazer um shell que execute várias substituições de caracter em
série, exemplo:

substituir todas as palavras "CACO" por "TEMP"
substituir todas as palavras "BOLA" por "CACO"
substituir todas as palavras "TEMP" por "BOLA"
substituir todas as palavras "CASA" por "TEMP"
substituir todas as palavras "CHUVA" por "CASA"
substituir todas as palavras "TEMP" por "CHUVA"

e assim por diante.
*/


O sed mata facil seu problema 

sed 's/CACO/TEMP/g'

Mudará todas as ocorrências de CACO para TEMP. Já que ambas estão entre
aspas, é só vc mudar a string em sí. 
Com base nisso, basta fazer um script com as regras. 

Me corrija se eu estiver enganado, mas o objetivo não seria "inverter" as
strings ? Por exemplo, CACO vira BOLA e BOLA vira CACO.
É isso ?

------------------------------------------
"There is still more Unix-nature in one
line of shell script than there is in ten
billion lines of C" 
Master Foo - Sh-bng Province - 530 B.C.
 
"Programar em shell scritp é a coisa mais gostosa que você pode fazer
vestido"
Julio C. Neves - 10/08/2005



reply via email to

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