pra não esquecer…

outubro 16th, 2007

egrep – grep com expressões regulares bota obra

Posted by Felipe Olivaes in Linux, xalassa

aeee precisando procurar uns arquivos por ereg?
mas ahh olha que obra:
find /tmp | egrep -i "gdb$|fdb$|gbak$|gbk$"

egrep é mto bom.. helpzinho rápido:
Uso: egrep [opção]… padrão [arquivo]…
Procura por PADRÃO em cada ARQUIVO ou entrada padrão.
Exemplo: egrep -i ‘hello world’ menu.h main.c

Seleção de expressão regular e interpretação:
-E, –extended-regexp PATTERN is an extended regular expression
-F, –fixed-strings PATTERN is a set of newline-separated strings
-G, –basic-regexp PATTERN is a basic regular expression
-P, –perl-regexp PATTERN is a Perl regular expression
-e, –regexp=PADRÃO use PADRÃO como uma expressão regular
-f, –file=ARQUIVO obtain PADRÃO from FILE
-i, –ignore-case ignora caixa do texto
-w, –word-regexp força PADRÃO encontrar apenas palavras inteiras
-x, –line-regexp força PADRÃO encontrar apenas linhas inteiras
-z, –null-data uma linha de dados acaba com 0 bytes, não nova linha

Miscelânea:
-s, –no-messages suprime mensagens de erro
-v, –revert-match seleciona somente linhas não coincidentes
-V, –version mostra informações sobre versão e sai
–help exibe esta ajuda e sai
–mmap usa entrada de memória mapeada se possível

Output control:
-m, –max-count=NUM stop after NUM matches
-b, –byte-offset print the byte offset with output lines
-n, –line-number print line number with output lines
–line-buffered flush output on every line
-H, –with-filename print the filename for each match
-h, –no-filename suppress the prefixing filename on output
–label=LABEL print LABEL as filename for standard input
-o, –only-matching show only the part of a line matching PATTERN
-q, –quiet, –silent suppress all normal output
–binary-files=TYPE assume that binary files are TYPE
TYPE is ‘binary’, ‘text’, or ‘without-match’
-a, –text equivalent to –binary-files=text
-I equivalent to –binary-files=without-match
-d, –directories=ACTION how to handle directories
ACTION is ‘read’, ‘recurse’, or ‘skip’
-D, –devices=ACTION how to handle devices, FIFOs and sockets
ACTION is ‘read’ or ‘skip’
-R, -r, –recursive equivalent to –directories=recurse
–include=PATTERN files that match PATTERN will be examined
–exclude=PATTERN files that match PATTERN will be skipped.
–exclude-from=FILE files that match PATTERN in FILE will be skipped.
-L, –files-without-match only print FILE names containing no match
-l, –files-with-matches only print FILE names containing matches
-c, –count only print a count of matching lines per FILE
-Z, –null print 0 byte after FILE name

Context control:
-B, –before-context=NUM print NUM lines of leading context
-A, –after-context=NUM print NUM lines of trailing context
-C, –context=NUM print NUM lines of output context
-NUM same as –context=NUM
–color[=WHEN],
–colour[=WHEN] use markers to distinguish the matching string
WHEN may be `always’, `never’ or `auto’.
-U, –binary do not strip CR characters at EOL (MSDOS)
-u, –unix-byte-offsets report offsets as if CRs were not there (MSDOS)

`egrep’ means `grep -E’. `fgrep’ means `grep -F’.
With no FILE, or when FILE is -, read standard input. If less than
two FILEs given, assume -h. Exit status is 0 if match, 1 if no match,
and 2 if trouble.

Leave a reply


 




nuvem de tags:

24 horas acentuação Apache bash benchmark bios boot celular centos charset comando console Download esxi Firebird firefox http importação intel ipod kinghost legenda Linux lost mod_deflate msn mssql MySQL owner Padel PHP placa mãe portabilidade Postgre SQL recovery root password rewrite shell sinuca sql server svn temporada completa veronica mars vmware Windows ícones