Olá pessoal primeira vez que partico do grupo... fiquei com uma
duvida sobre o comando grep
na opção que o Marlon passou funciona perfeito
mas somente quando um arquivo esteja comentado e o primeiro caracter
da linha seja '#'
e no caso de um arquivo começar com espaços e depois vem o comentario
(#)?
exemplo:
grep -v ^# apache2.conf
<IfModule alias_module>
#
# Aliases: Add here as many aliases as you need (with no limit).
The format is
# Alias fakename realname
#
# Note that if you include a trailing / on fakename then the
server will
# require it to be present in the URL. So "/icons" isn't aliased
in this
# example, only "/icons/". If the fakename is slash-terminated,
then the
# realname must also be slash terminated, and if the fakename
omits the
# trailing slash, the realname must also omit it.
#
# We include the /icons/ alias for FancyIndexed directory
listings. If
# you do not use FancyIndexing, you may comment this out.
#
--- Em [email protected], "marlon_mca" <[EMAIL PROTECTED]> escreveu
>
> Amigo no grep vc só precisa fazer assim:
> grep -v ^# /etc/squid/squid.conf
>
> mas pra coisas mais complexas, onde vc precise de mais expressões o
> egrep é melhor.
>
>
>
> --- Em [email protected], "fttmadeira" <fmadeira@> escreveu
> >
> > Pessoal,
> >
> > Estou querendo ver apenas o conteúdo não comentado de um arquivo
de
> > configuração.
> >
> > Através do comando egrep eu consigo beleza, tentando com o grep
passando
> > a opção -v não funciona.
> >
> > Segue abaixo como estou fazendo:
> >
> > Caso 1: egrep
> >
> > [EMAIL PROTECTED] conf]$ cat httpd.conf | egrep -v '(^#)'
> > ServerTokens OS
> > ServerRoot "/etc/httpd"
> > PidFile run/httpd.pid
> > Timeout 120
> > KeepAlive Off
> > MaxKeepAliveRequests 100
> >
> > Caso 2: grep
> > [EMAIL PROTECTED] conf]$ cat httpd.conf | grep -v '(^#)'
> > #
> > # If you would like to have separate agent and referer logfiles,
> > # uncomment
> > # the following directives.
> > #
> > #CustomLog logs/referer_log referer
> > #CustomLog logs/agent_log agent
> > #
> > # For a single logfile with access, agent, and referer information
> > # (Combined Logfile Format), use the following directive:
> > #
> > CustomLog logs/access_log combined
> >
> > Através do grep --help eu tenho:
> > -v, --revert-match seleciona somente linhas não
coincidentes
> >
> > Por que o comando não funciona com o grep ?
> >
> > PS: Como faço par remover as linhas em branco da saída do egrep ?
> >
> > Abraços
> >
> > --
> > Frederico Madeira
> > www.madeira.eng.br
> > GPG-Key-ID: 1024D/0F0A721D
> > Key fingerprint = C424 D86B 57D5 BE55 767A 6ED1 53F8 254E 0F0A
721D
> > Cisco CCNA, LPIC-1
> >
>