Na verdade eu quero limpar tudo, exceto o nome das macros. Mas com sua ajuda eu consegui avançar:
$ sed 's/\\\n//' <<end | grep -h "^ *\# *if\(def\|ndef\|\)\>" | sed 's/# *if[a-z]*\> *\|defined\|[^A-Za-z_0-9]\+ *\|\<[0-9]\+\>/ /g;s/^ \+\| \+$//;s/ \+/\n/g' > #if defined( XXX ) && (defined( YYY ) || !defined( ZZZ ) || ZZZ == 123) > #if defined( XXX ) \ > || defined( ZZZ ) > end XXX YYY ZZZ ZZZ XXX ZZZ O que eu achei estranho foi eu ter conseguido limpar os espaços do início das linhas (exp: "^ \+") mas não os espaços no final das linhas (exp: " \+$"), porém não tem importância, consegui uma mega linha de comando: $ for DEF in $(cat *.{cpp,h} | sed 's/\\\n//' | grep -h "^ *\# *if\(def\|ndef\|\)\>" | sed 's/# *if[a-z]*\> *\|defined\|[^A-Za-z_0-9]\+ *\|\<[0-9]\+\>/ /g;s/^ \+\| \+$//;s/ \+/\n/g' | grep -v "^[A-Za-z]\+H$" | sort -u) ; do if ! grep -q "\# *define *$DEF" Local/Local.h ; then echo $DEF ; fi ; done CAD_PRO_CLEAR_LOCFORM SCF_CH_BALCAO SCF_ORC_LIMBALCAO SCF_ORC_PRECO_CPAG SISDEMO SISQUERY SISRENT Obrigado pela ajuda. > -----Original Message----- > From: César Vianna > > sed ajuda > > echo "if defined( XXX ) || defined( YYY )"| sed 's/||/\n||/' > > > > 2009/8/18 Márcio Gil <marciom...@bol.com.br> > > > > > > > Colegas, > > > > Eu executei a seguinte consulta, visando localizar diretivas > > #ifdef/#ifndef que não constam em um arquivo de opções do programa > > chamado Local.h: > > > > $ for DEF in $(grep -h "^\# *ifn\?def *" *.cpp | sed "s/^\# > > *ifn\?def *//" | sort -u) ; do if ! grep -q "\# *define *$DEF" > > Local/Local.h ; then echo $DEF ; fi ; done > > CAD_PRO_CLEAR_LOCFORM > > SCF_CH_BALCAO > > SCF_ORC_PRECO_CPAG > > SISQUERY > > > > Funcionou perfeito para as diretivas #ifdef e #ifndef, agora eu > > queria extrair as variaveis contidas em diretivar #if, na forma: > > > > #if defined( XXX ) && defined( YYY ) > > > > ou > > > > #if defined( XXX ) || !defined( YYY ) > > > > etc. > > > > Quero que o comando retorne XXX e YYY em linhas separadas ou > > separadas por um espaço. Agora o problema mesmo será quebrar linhas > > assim: > > > > #if defined( XXX ) \ > > || defined( YYY ) > > > > alguem me dá alguma sugestão? > > > > Obrigado, > > > > Marcio Gil. > > > > > > >