.\" -*- coding: UTF-8 -*- .de dT .ds Dt \\$2 .. .\" GNU grep man page .dT Time-stamp: 2019-12-29 .\" Update the above date whenever a change to either this file or .\" grep.c's 'usage' function results in a nontrivial change to the man page. .\" In Emacs, you can update the date by running 'M-x time-stamp' .\" after you make a change that you decide is nontrivial. .\" It is no big deal to forget to update the date. . .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH GREP 1 \*(Dt "GNU grep 3.11" "Órdenes de usuario" . .if !\w|\*(lq| \{\ .\" groff an-old.tmac does not seem to be in use, so define lq and rq. . ie \n(.g \{\ . ds lq \(lq\" . ds rq \(rq\" . \} . el \{\ . ds lq `` . ds rq '' . \} .\} . .if !\w|\*(la| \{\ .\" groff an-ext.tmac does not seem to be in use, so define the parts of .\" it that are used below. For a copy of groff an-ext.tmac, please see: .\" https://git.savannah.gnu.org/cgit/groff.git/plain/tmac/an-ext.tmac .\" --- Start of lines taken from groff an-ext.tmac . .\" Check whether we are using grohtml. .nr mH 0 .if \n(.g \ . if '\*(.T'html' \ . nr mH 1 . . .\" Map mono-width fonts to standard fonts for groff's TTY device. .if n \{\ . do ftr CR R . do ftr CI I . do ftr CB B .\} . .\" groff has glyph entities for angle brackets. .ie \n(.g \{\ . ds la \(la\" . ds ra \(ra\" .\} .el \{\ . ds la <\" . ds ra >\" . \" groff's man macros control hyphenation with this register. . nr HY 1 .\} . .\" Start URL. .de UR . ds m1 \\$1\" . nh . if \\n(mH \{\ . \" Start diversion in a new environment. . do ev URL-div . do di URL-div . \} .. . . .\" End URL. .de UE . ie \\n(mH \{\ . br . di . ev . . \" Has there been one or more input lines for the link text? . ie \\n(dn \{\ . do HTML-NS "" . \" Yes, strip off final newline of diversion and emit it. . do chop URL-div . do URL-div . do HTML-NS . \} . el \ . do HTML-NS "\\*(m1" \&\\$*\" . \} . el \ \\*(la\\*(m1\\*(ra\\$*\" . . hy \\n(HY .. . . .\" Start email address. .de MT . ds m1 \\$1\" . nh . if \\n(mH \{\ . \" Start diversion in a new environment. . do ev URL-div . do di URL-div . \} .. . . .\" End email address. .de ME . ie \\n(mH \{\ . br . di . ev . . \" Has there been one or more input lines for the link text? . ie \\n(dn \{\ . do HTML-NS "" . \" Yes, strip off final newline of diversion and emit it. . do chop URL-div . do URL-div . do HTML-NS . \} . el \ . do HTML-NS "\\*(m1" \&\\$*\" . \} . el \ \\*(la\\*(m1\\*(ra\\$*\" . . hy \\n(HY .. .\" --- End of lines taken from groff an-ext.tmac .\} . .hy 0 . .SH NOMBRE grep, egrep, fgrep \- rgrep \- muestran líneas que concuerdan con un patrón . .SH SINOPSIS \fBgrep\fP [\fIOPCIÓN\fP.\|.\|.]\& \fIPATRONES\fP [\fIARCHIVO\fP.\|.\|.] .br \fBgrep\fP [\fIOPCIÓN\fP.\|.\|.]\& \fB\-e\fP \fIPATRONES\fP \&.\|.\|.\& [\fIARCHIVO\fP.\|.\|.] .br \fBgrep\fP [\fIOPCIÓN\fP.\|.\|.]\& \fB\-f\fP \fIARCHIVO_PATRÓN\fP \&.\|.\|.\& [\fIARCHIVO\fP.\|.\|.] . .SH DESCRIPCIÓN \fBgrep\fP busca \fIPATRONES\fP en cada \fIARCHIVO\fP. \fIPATRONES\fP consistirá en uno o más patrones separados entre sí por un salto de línea; \fBgrep\fP mostrará cada línea donde encuentre una concordancia con dicho patrón. En general, deben entrecomillarse los patrones si se ejecut \fBgrep\fP dentro de otra orden de la shell. .PP Si definimos \fIARCHIVO\fP como '\fB\-\fP', se considerará la entrada estándar. Si nose define ningún valor para \fIARCHIVO\fP, se hará una búsqueda recursiva del directorio actual y no recursiva de la entrada estándar. .PP Debian also includes the variant programs \fBegrep\fP, \fBfgrep\fP and \fBrgrep\fP. These programs are the same as \fBgrep\ \-E\fP, \fBgrep\ \-F\fP, and \fBgrep\ \-r\fP, respectively. These variants are deprecated upstream, but Debian provides for backward compatibility. For portability reasons, it is recommended to avoid the variant programs, and use \fBgrep\fP with the related option instead. . .SH OPCIONES .SS "Información genérica de la aplicación" .TP \fB\-\^\-help\fP Muestra una breve instrucción de uso y finaliza. .TP \fB\-V\fP, \fB\-\^\-version\fP Muestra la versión de \fBgrep\fP y termina. .SS "Sintaxis del patrón" .TP \fB\-E\fP, \fB\-\^\-extended\-regexp\fP Interpreta \fIPATRONES\fP como una expresión regular extendida (vea más adelante). .TP \fB\-F\fP, \fB\-\^\-fixed\-strings\fP Interpreta \fIPATRONES\fP como una cadena de texto, no como expresiones regulares. .TP \fB\-G\fP, \fB\-\^\-basic\-regexp\fP Interpreta \fIPATRONES\fP como una expresión regular básica (vea más abajo). Éste es el comportamiento predeterminado. .TP \fB\-P\fP, \fB\-\^\-perl\-regexp\fP Interpreta \fIPATRONES\fP como un expresión regular de Perl (PCRE). Esta opción aún es experimental si se combina con \fB\-z\fP (\fB\-\^\-vacío\fP), \fBgrep \-P\fP puede emitir avisos acerca de funciones no implementadas. .SS "Gestión de las concordancias" .TP \fB\-e\fP\fI PATRONES\fP,\fB \-\^\-regexp=\fP\fIPATRONES\fP Emplea \fIPATRONES\fP como patrones. Si se usa varias veces o se combina con la opción \fB\-f\fP (\fB\-\^\-file\fP) la búsqueda se realizará con todos los patrones dado. Esta opción es útil para proteger un patrón que comience por '\-'. .TP \fB\-f\fP\fI ARCHIVO\fP,\fB \-\^\-file=\fP\fIARCHIVO\fP Obtiene el patrón de \fIARCHIVO\fP, uno de cada línea. Si se emplea esta opción varias veces o se combina con \fB\-e\fP (\fB\-\^\-regexp\fP) realiza la búsqueda con todos los patrones que se indiquen. Un archivo vacío contiene cero patrones y no concordará con nada. Si \fIARCHIVO\fP es \fB\-\fP, tomará los patrones desde la entrada estándar. .TP \fB\-i\fP, \fB\-\^\-ignore\-case\fP No distingue entre mayúsculas y minúsculas tanto en los patrones como en los datos de entrada, así que los caracteres que sólo difieran en este aspecto resultarán en una coincidencia. .TP \fB\-\^\-no\-ignore\-case\fP Distingue entre mayúsculas y minúsculas tanto en los patrones como en los datos de entrada (comportamiento por defecto). Esta opción es útil en el caso de emplearse en scripts de shell donde se haya definido previamente la opción \fB\-i\fP ya que ambas opciones se anulan entre sí. .TP \fB\-v\fP, \fB\-\^\-invert\-match\fP Invierte el sentido de la concordancia, seleccionando las líneas que no concuerden. .TP \fB\-w\fP, \fB\-\^\-word\-regexp\fP Selecciona solamente aquellas líneas que contienen concordancias que forman palabras completas. La comprobación consiste en que la cadena de caracteres concordante debe estar al principio de la línea o precedida por un carácter que no forme parte de una palabra. De forma similar, debe estar o al final de la línea o ser seguida por un carácter no constituyente de palabra. Los caracteres que se consideran como parte de palabras son letras, dígitos y el subrayado. No tiene efecto si también de define la opción \fB\-x\fP. .TP \fB\-x\fP, \fB\-\^\-line\-regexp\fP Selecciona únicamente las línea que concuerden completa y exactamente en su totalidad con el patrón. Equivaldría, en el caso de una expresión regular, a definir el patrón entre paréntesis comenzando con \fB^\fP y finalizando con \fB$\fP. .SS "Gestión general de la salida" .TP \fB\-c\fP, \fB\-\^\-count\fP Suprime la salida normal; en su lugar muestra el número de líneas que concuerdan con el patrón para cada archivo de entrada. Con la opción \fB\-v\fP, \fB\-\^\-invert\-match\fP, contabiliza el número de líneas que no concuerdan. .TP \fB\-\^\-color\fP[\fB=\fP\fICUANDO\fP], \fB\-\^\-colour\fP[\fB=\fP\fICUANDO\fP] Rodea las cadenas concordantes (que no estén en blanco), líneas concordantes, nombres de archivo, números de línea, bytes de compensación y separadores (para los campos y grupos de líneas contextuales) con secuencias de escape para mostrarlas en distintos colores a través del terminal. Dichos colores se definen a través de la variable de entorno \fBGREP_COLORS\fP. Los colores se definen mediante las variables de entorno . \fICUANDO\fP puede tener tres valores diferentes: \fBnever\fP (nunca), \fBalways\fP (siempre) o \fBauto\fP. .TP \fB\-L\fP, \fB\-\^\-files\-without\-match\fP Suprime la salida normal; en su lugar muestra el nombre de cada archivo de entrada donde no se encuentre ninguna concordancia y por lo tanto de cada fichero que no produciría ninguna salida. .TP \fB\-l\fP, \fB\-\^\-files\-with\-matches\fP Suprime la salida normal; en su lugar muestra el nombre de cada fichero de entrada que produciría alguna salida. La búsqueda de cada entrada se detendrá en la primera concordancia. .TP \fB\-m\fP\fI NÚM\fP,\fB \-\^\-max\-count=\fP\fINÚM\fP Deja de leer un archivo al alcanzar la cantidad de \fINUM\fP líneas concordantes. Si \fINUM\fP es cero, \fBgrep\fP se detiene de inmediato sin leer ninguna entrada. Si \fINUM\fP es \-1, se considera como infinito y \fBgrep\fP nunca se detiene; éste es el comportamiento por defecto. Si la entrada es un archivo corriente y la salida son las \fINUM\fP líneas concordantes, \fBgrep\fP hará que el archivo de entrada quede posicionado justo después de la última línea concordante sin importar la existencia de alguna línea contextual posterior. Así, un proceso posterior podrá continuar con la búsqueda. Cuando \fBgrep\fP se detiene después de encontrar \fINUM\fP líneas concordantes, mostrará sus líneas contextuales. Si se usa la opción \fB\-c\fP o \fB\-\^\-count\fP, nunca se mostrará un recuento superior a \fINUM\fP. Con la opción \fB\-v\fP o \fB\-\^\-invert\-match\fP, la ejecución de \fBgrep\fP se detendrá una vez mostradas \fINUM\fP líneas no concordantes. .TP \fB\-o\fP, \fB\-\^\-only\-matching\fP Muestra sólo la parte coincidente con el patrón de una línea concordante, siempre que no sea una cadena vacía y poniendo cada parte en una línea diferente. .TP \fB\-q\fP, \fB\-\^\-quiet\fP, \fB\-\^\-silent\fP Mínima salida. No muestra nada en la salida estándar. Termina con estado cero si encuentra alguna concordancia aunque detecte algún error. Consulte también la opción \fB\-s\fP o \fB\-\^\-no\-messages\fP. .TP \fB\-s\fP, \fB\-\^\-no\-messages\fP Suprime los mensajes de error sobre archivos que no existen o no se pueden leer. .SS "Muestra un prefijo de control en cada línea" .TP \fB\-b\fP, \fB\-\^\-byte\-offset\fP Muestra el desplazamiento de bytes, comenzando en cero, dentro del archivo de entrada antes de cada línea mostrada. Si se define \fB\-o\fP (\fB\^\-only\-matching\fP), muestra el desplazamiento de la parte concordante. .TP \fB\-H\fP, \fB\-\^\-with\-filename\fP Muestra el nombre del archivo donde se produjo la concordancia. Esto se hará por defecto cuando se busque en más de un archivo. Es una extensión de GNU. .TP \fB\-h\fP, \fB\-\^\-no\-filename\fP No muestra los nombres de archivo antes de cada línea. Es el comportamiento por defecto cuando se realiza la búsqueda en un solo archivo o en la entrada estandar. .TP \fB\-\^\-label=\fP\fIETIQUETA\fP Muestra la entrada provienente de la entrada estándar como entrada proveniente del archivo \fILABEL\fP. Esto puede ser útil para las órdenes que transforman el contenido de un archivo antes de realizar la búsqueda. Por ejemplo: \fBgzip \-cd foo.gz | grep \-\-label=foo \-H 'algún patrón'\fP. Consulte también la opción \-H. .TP \fB\-n\fP, \fB\-\^\-line\-number\fP Antepone a cada línea mostrada el número de línea de su archivo de entrada correspondiente comenzando por el 1. .TP \fB\-T\fP, \fB\-\^\-initial\-tab\fP Se asegura que el primer carácter de la línea actual esté en una tabulación, de modo que la alíneación de las tabulaciones parezca normal. Esto es útil con las opciones que anteponen su salida al contenido real: \fB\-H\fP, \fB\-n\fP y \fB\-b\fP. Para incrementar la probabilidad de que todas las líneas de un mismo archivo comiencen en la misma columna, también hace que el número de línea y el desplazamiento de bytes (si existe) se impriman en un ancho de campo mínimo. .TP \fB\-Z\fP, \fB\-\^\-null\fP Muestra un byte cero (el carácter ASCII \fBNUL\fP) en lugar del carácter que habitualmente seguiría al nombre de un archivo. Por ejemplo: \fBgrep \-lZ\fP genera un byte cero después de cada nombre de archivo en lugar del salto de línea habitual. Esta opción hace que la salida no sea ambigua, incluso con nombres de archivo que contengan caracteres poco usuales como saltos de línea. Esta opción se puede usar con órdenes como \fBfind \-print0\fP, \fBperl \-0\fP, \fBsort \-z\fP y \fBxargs \-0\fP para procesar nombres de archivos arbitrarios, incluso aquellos que contienen saltos de línea en su nombre. .SS "Gestión de Líneas Contextuales" .TP \fB\-A\fP\fI NÚM\fP,\fB \-\^\-after\-context=\fP\fINÚM\fP Imprime \fINUM\fP líneas de contexto posterior después de las líneas concordantes. Coloca una línea que contiene un separador de grupo (\fB\-\^\-\fP) entre grupos contiguos de coincordancias. Con la opción \fB\-o\fP o \fB\-\^\-only\-matching\fP, se emitirá un mensaje de advertencia y no tendrá ningún efecto. .TP \fB\-B\fP\fI NÚM\fP,\fB \-\^\-before\-context=\fP\fINÚM\fP Imprime \fINUM\fP cantidad de líneas de contexto respecto de la concordante. Añade un separador (\fB\-\^\-\fP) entre grupos de concordancias. Si se emplea con la opción \fB\-o\fP o \fB\-\^\-only\-matching\fP, no tendrá ningún efecto y se emitirá un aviso. .TP \fB\-C\fP\fI NÚM\fP,\fB \-\fP\fINÚM\fP,\fB \-\^\-context=\fP\fINÚM\fP Muestra \fINUM\fP líneas contextuales. Inserta una línea con un separador (\fB\-\[ -\fP) entre grupos contiguos de concordancias. Si se usa la opción \fB-o\fP o \fB-\^-only-matching\fP, se emite un mensaje de advertencia y no tendrá ningún efecto. .TP \fB\-\^\-group\-separator=\fP\fISEP\fP Cuando se usen las opciones \fB\-A\fP, \fB\-B\fP o \fB\-C\fP, emplea \fISEP\fP en lugar de \fB\-\^\-\fP entre los distintos grupos de líneas. .TP \fB\-\^\-no\-group\-separator\fP Cuando se usen las opciones \fB\-A\fP, \fB\-B\fP o \fB\-C\fP, no me mostrará ningún separador entre líneas. .SS "Selección de archivos y directorios" .TP \fB\-a\fP, \fB\-\^\-text\fP Procesa un archivo binario como si se tratase de texto. Equivale a la opción \fB\-\^\-binary\-files=text\fP. .TP \fB\-\^\-binary\-files=\fP\fITIPO\fP Si los datos o metadatos de un archivo indican que su contenido es binario, asume que dicho archivo es del tipo \fITIPO\fP. Los bytes que no codifican texto, indican que el contenido es binario; estos podrán ser bytes incorrectamente codificados para la localización en uso o bytes nulos si no se indicó la opción \fB\-z\fP. .IP Por defecto, \fITIPO\fP se considera \fBbinary\fP, con lo cual \fBgrep\fP elimina cualquier salida si se encuentra con datos binarios o datos incorrectamente codificados. Cada vez que se elimina algo en la salida, \fBgrep\fP mostrará un mensaje en la salida de error estándar informando de la concordancia con un archivo binario. .IP Si \fITIPO\fP es \fBwithout\-match\fP, \fBgrep\fP asumirá que no hay concordancia alguna en el resto del archivo si se encuentra contenido nulo binarios. Esto equivale a la opción \fB\-I\fP. .IP Si \fITIPO\fP es \fBtexto\fP, \fBgrep\fP procesará un archivo binario como si se tratase de texto. Equivale a la opción \fB\-a\fP. .IP Cuando el \fItipo\fP es \fBbinario\fP, \fBgrep\fP puede tratar los bytes no\-textuales como terminadores de línea incluso sin la opción \fB\-z\fP. Esto significa que elegir \fBbinario\fP frente a \fBtexto\fP puede afectar si un patrón coincide con un archivo. Por ejemplo, cuando \fItipo\fP es \fBbinario\fP, el patrón \fBq$ podría\fP coincidir con \fBq\fP seguido inmediatamente de un byte nulo, aunque esto no concorde cuando el \fItipo\fP es \fBtexto\fP. Por el contrario, cuando el \fItipo\fP es \fBbinario\fP, el patrón \fB.\&\fP (punto) puede no coincidir con un byte nulo. .IP \fIWarning:\fP The \fB\-a\fP option might output binary garbage, which can have nasty side effects if the output is a terminal and if the terminal driver interprets some of it as commands. On the other hand, when reading files whose text encodings are unknown, it can be helpful to use \fB\-a\fP or to set \fBLC_ALL='C'\fP in the environment, in order to find more matches even if the matches are unsafe for direct display. .TP \fB\-D\fP\fI ACCIÓN\fP,\fB \-\^\-devices=\fP\fIACCIÓN\fP If an input file is a device, FIFO or socket, use \fIACTION\fP to process it. By default, \fIACTION\fP is \fBread\fP, which means that devices are read just as if they were ordinary files. If \fIACTION\fP is \fBskip\fP, devices are silently skipped. .TP \fB\-d\fP\fI ACCIÓN\fP\fB, \-\-directories=\fP\fIACCIÓN\fP Emplea \fIACCIÓN\fP para procesar el archivo de entrada si éste es un directorio. Por defecto, esta \fIACCIÓN\fP es \fBread\fP (leer), esto es que leerá directorios tal como si fuesen archivos. Si \fIACCIÓN\fP es \fBskip\fP, se saltará los directorios sin emitir ningún mensaje. Por último, si \fIACCIÓN\fP es \fBrecurse\fP, leerá de forma recusiva todos los archivos que se encuentren dentro de cada directorio siguiendo los enlaces simbólicos sólo si se indican en la línea de órdenes. Esto equivaldría a definir la opción \fB\-r\fP. .TP \fB\-\^\-exclude=\fP\fIGLOB\fP Skip any command\-line file with a name suffix that matches the pattern \fIGLOB\fP, using wildcard matching; a name suffix is either the whole name, or a trailing part that starts with a non\-slash character immediately after a slash (\fB/\fP) in the name. When searching recursively, skip any subfile whose base name matches \fIGLOB\fP; the base name is the part after the last slash. A pattern can use \fB*\fP, \fB?\fP, and \fB[\fP.\|.\|.\fB]\&\fP as wildcards, and \fB\e\fP to quote a wildcard or backslash character literally. .TP \fB\-\^\-exclude\-from=\fP\fIARCHIVO\fP Ignora archivos cuya base del nombre coincida con alguna de las expresiones contenidas en \fIARCHIVO\fP (empleando concordancias tal como se describió en \fB\-\^\-exclude\fP). .TP \fB\-\^\-exclude\-dir=\fP\fIGLOB\fP Salta cualquier directorio cuyo sufijo concuerde con el patrón \fIGLOB\fP. Cuando se hace una búsqueda recursiva, saltará cualquier subdirectorio cuya base del nombre concuerde con \fIGLOB\fP. No tiene en cuenta las barras al final de \fIGLOB\fP. .TP \fB\-I\fP Procesa un archivo binario como si no contuviese ninguna concordancia. Equivale a la opción \fB\-\^\-binary\-files=without\-match\fP. .TP \fB\-\^\-include=\fP\fIGLOB\fP Search only files whose base name matches \fIGLOB\fP (using wildcard matching as described under \fB\-\^\-exclude\fP). If contradictory \fB\-\^\-include\fP and \fB\-\^\-exclude\fP options are given, the last matching one wins. If no \fB\-\^\-include\fP or \fB\-\^\-exclude\fP options match, a file is included unless the first such option is \fB\-\^\-include\fP. .TP \fB\-r\fP, \fB\-\^\-recursive\fP Lee recursivamente todos los archivos dentro de cada directorio, sigue enlaces simbólicos sólo si están en la línea de órdenes. Observe que si no se indica ningún archivo, \fBgrep\fP buscará en el directorio actual. Equivale a la opción \fB\-d recurse\fP. .TP \fB\-R\fP, \fB\-\^\-dereference\-recursive\fP Lee recursivamente todos los archivos dentro de cada directorio. Sigue todos los enlaces simbólicos a diferencia de \fB\-r\fP. .SS "Otras opciones" .TP \fB\-\^\-line\-buffered\fP Emplea el bufer de línea para la salida. Puede provocar un descenso del rendimiento. .TP \fB\-U\fP, \fB\-\^\-binary\fP Trata el(los) fichero(s) como binario(s). De forma predeterminada, en MS\-DOS y MS\-Windows, \fBgrep\fP intenta adivinar el tipo de archivo tal como se describe para la opción \fB\-\^\-binary\-files\fP. Si \fBgrep\fP decide que el fichero es de texto, quita los caracteres CR (retorno de carro) de los contenidos originales del fichero (para que las expresiones regulares con \fB^\fP y \fB$\fP funcionen correctamente). Al especificar \fB\-U\fP deshabilitamos este intento de adivinación del tipo del fichero, haciendo que todos se lean y pasen al mecanismo de concordancia tal cuales; si el fichero lo es de texto y tiene al final de cada línea el par de caracteres CR/LF, esto hará que algunas expresiones regulares fallen. Esta opción solo tiene sentido en MS\-DOS y MS\-Windows. .TP \fB\-z\fP, \fB\-\^\-null\-data\fP Treat input and output data as sequences of lines, each terminated by a zero byte (the ASCII NUL character) instead of a newline. Like the \fB\-Z\fP or \fB\-\^\-null\fP option, this option can be used with commands like \fBsort \-z\fP to process arbitrary file names. . .SH "EXPRESIONES REGULARES" Una expresión regular es un patrón que describe un conjunto de cadenas de caracteres. Las expresiones regulares se construyen de forma análoga a las expresiones aritméticas, combinando expresiones más pequeñas mediante ciertos operadores para formar expresiones complejas. .PP \fBgrep\fP understands three different versions of regular expression syntax: \*(lqbasic\*(rq (BRE), \*(lqextended\*(rq (ERE) and \*(lqperl\*(rq (PCRE). In GNU \fBgrep\fP, basic and extended regular expressions are merely different notations for the same pattern\-matching functionality. In other implementations, basic regular expressions are ordinarily less powerful than extended, though occasionally it is the other way around. The following description applies to extended regular expressions; differences for basic regular expressions are summarized afterwards. Perl\-compatible regular expressions have different functionality, and are documented in \fBpcre2syntax\fP(3) and \fBpcre2pattern\fP(3), but work only if PCRE support is enabled. .PP Los bloques de construcción fundamentales son las expresiones regulares que concuerdan con un solo carácter. La mayoría de los caracteres, incluyendo todas las letras y dígitos, son expresiones regulares que concuerdan consigo mismos. Cualquier meta\-carácter con un significado especial debe ser protegido precediéndolo con una barra inclinada inversa. .PP El punto \fB.\&\fP concuerda con un único carácter, cualquiera que sea. No está definido el comportamiento si se topa con un error de codificación. .SS "Grupos de caracters y Expresiones entre Corchetes" A \fIbracket expression\fP is a list of characters enclosed by \fB[\fP and \fB]\fP. It matches any single character in that list. If the first character of the list is the caret \fB^\fP then it matches any character \fInot\fP in the list; it is unspecified whether it matches an encoding error. For example, the regular expression \fB[0123456789]\fP matches any single digit. .PP Within a bracket expression, a \fIrange expression\fP consists of two characters separated by a hyphen. It matches any single character that sorts between the two characters, inclusive, using the locale's collating sequence and character set. For example, in the default C locale, \fB[a\-d]\fP is equivalent to \fB[abcd]\fP. Many locales sort characters in dictionary order, and in these locales \fB[a\-d]\fP is typically not equivalent to \fB[abcd]\fP; it might be equivalent to \fB[aBbCcDd]\fP, for example. To obtain the traditional interpretation of bracket expressions, you can use the C locale by setting the \fBLC_ALL\fP environment variable to the value \fBC\fP. .PP Finally, certain named classes of characters are predefined within bracket expressions, as follows. Their names are self explanatory, and they are \fB[:alnum:]\fP, \fB[:alpha:]\fP, \fB[:blank:]\fP, \fB[:cntrl:]\fP, \fB[:digit:]\fP, \fB[:graph:]\fP, \fB[:lower:]\fP, \fB[:print:]\fP, \fB[:punct:]\fP, \fB[:space:]\fP, \fB[:upper:]\fP, and \fB[:xdigit:]\fP. For example, \fB[[:alnum:]]\fP means the character class of numbers and letters in the current locale. In the C locale and ASCII character set encoding, this is the same as \fB[0\-9A\-Za\-z]\fP. (Note that the brackets in these class names are part of the symbolic names, and must be included in addition to the brackets delimiting the bracket expression.) Most meta\-characters lose their special meaning inside bracket expressions. To include a literal \fB]\fP place it first in the list. Similarly, to include a literal \fB^\fP place it anywhere but first. Finally, to include a literal \fB\-\fP place it last. .SS Anclado El símbolo de intercalación (caret en inglés) \fB^\fP y el dólar \fB$\fP son metacaracteres que concuerdan respectivamente con una cadena vacía al inicio y al final de una línea. .SS "La Barra Invertida y otras Expresiones Especiales" Los símbolos \fB\e<\fP y \fB\e>\fP concuerdan con una cadena vacía al inicio y al fina de una palabra, respetivamente. El símbolo \fB\eb\fP concuerda con una cadena vacía en los extremos de una palabra y \fB\EB\fP hará lo propio si dicha cadena vacío \fINO\fP está en los extremos de una palabra. El símbolo \fB\ew\fP es sinómino de \fB[_[:alnum:]]\fP y \fB\eW\fP lo es de \fB[^_[:alnum:]]\fP. .SS Repetición Una expresión regular que concuerde con un solo carácter puede ser seguida por uno de estos varios operadores de repetición: .PD 0 .TP \fB?\fP El elemento precedente es opcional y concuerda como mucho una vez. .TP \fB*\fP El elemento precedente concordará cero o más veces. .TP \fB+\fP El elemento precedente concordará una o más veces. .TP \fB{\fP\fIn\fP\fB}\fP El elemento precedente concuerda exactamente \fIn\fP veces. .TP \fB{\fP\fIn\fP\fB,}\fP El elemento precedente concuerda \fIn\fP o más veces. .TP \fB{,\fP\fIm\fP\fB}\fP El elemento precedente concuerda un máximo de \fIm\fP veces. Es una extensión de GNU. .TP \fB{\fP\fIn\fP\fB,\fP\fIm\fP\fB}\fP El elemento precedente concuerda como poco \fIn\fP veces, pero no más de \fIm\fP veces. .PD .SS Concatenación Dos expresiones regulares pueden concatenarse; la expresión regular resultante concuerda con cualquier cadena formada mediante la concatenación de dos subcadenas que concuerdan respectivamente con las expresiones concatenadas. .SS Alternancia Dos expresiones regulares pueden juntarse mediante el operador \fB|\fP; la expresión regular resultante concuerda con cualquier cadena que concuerde con cualquiera de las expresiones. .SS Precedencia La repetición tiene precedencia sobre la concatenación, la cual a su vez tiene precedencia sobre la alternancia. Una expresión entera puede ser encerrada entre paréntesis para subvertir estas reglas de precedencia. .SS "Retroreferencias y Subexpresiones" The back\-reference \fB\e\fP\fIn\fP \&, where \fIn\fP is a single digit, matches the substring previously matched by the \fIn\fPth parenthesized subexpression of the regular expression. .SS "Expresiones Regulares Básicas y Ampliadas" En las expresiones regulares básicas, los metacaracteres \fB?\fP, \fB+\fP, \fB{\fP, \fB|\fP, \fB(\fP, y \fB)\fP pierden su significado especial; en su lugar emplee las versiones protegidas mediante la barra inversa \fB\e?\fP, \fB\e+\fP, \fB\e{\fP, \fB\e|\fP, \fB\e(\fP, y \fB\e)\fP. . .SH "ESTADO DE SALIDA" El estado de salida suele ser 0 si se ha seleccinado alguna línea, 1 si no se ha seleccionado ninguna y 2 si ha ocurrido algún error. Sin embargo, si se indicó la opción \fB\-q\fP o \fB\-\^\-quiet\fP o \fB\-\^\-silent\fP el estado de salida será cero aunque ocurriese algún error. . .SH ENTORNO El comportamiento de \fBgrep\fP está influido por las siguientes variables de entorno. .PP The locale for category \fBLC_\fP\fIfoo\fP is specified by examining the three environment variables \fBLC_ALL\fP, \fBLC_\fP\fIfoo\fP, \fBLANG\fP, in that order. The first of these variables that is set specifies the locale. For example, if \fBLC_ALL\fP is not set, but \fBLC_MESSAGES\fP is set to \fBpt_BR\fP, then the Brazilian Portuguese locale is used for the \fBLC_MESSAGES\fP category. The C locale is used if none of these environment variables are set, if the locale catalog is not installed, or if \fBgrep\fP was not compiled with national language support (NLS). The shell command \fBlocale \-a\fP lists locales that are currently available. .TP \fBGREP_COLORS\fP Controls how the \fB\-\^\-color\fP option highlights output. Its value is a colon\-separated list of capabilities that defaults to \fBms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36\fP with the \fBrv\fP and \fBne\fP boolean capabilities omitted (i.e., false). Supported capabilities are as follows. .RS .TP \fBsl=\fP SGR substring for whole selected lines (i.e., matching lines when the \fB\-v\fP command\-line option is omitted, or non\-matching lines when \fB\-v\fP is specified). If however the boolean \fBrv\fP capability and the \fB\-v\fP command\-line option are both specified, it applies to context matching lines instead. The default is empty (i.e., the terminal's default color pair). .TP \fBcx=\fP SGR substring for whole context lines (i.e., non\-matching lines when the \fB\-v\fP command\-line option is omitted, or matching lines when \fB\-v\fP is specified). If however the boolean \fBrv\fP capability and the \fB\-v\fP command\-line option are both specified, it applies to selected non\-matching lines instead. The default is empty (i.e., the terminal's default color pair). .TP \fBrv\fP Valor booleano que invierte el significado de las capacidades \fBsl=\fP y \fBcx=\fPcuando se define la opción \fB\-v\fP. Por defecto es falso, es decir que se omite la capacidad. .TP \fBmt=01;31\fP SGR substring for matching non\-empty text in any matching line (i.e., a selected line when the \fB\-v\fP command\-line option is omitted, or a context line when \fB\-v\fP is specified). Setting this is equivalent to setting both \fBms=\fP and \fBmc=\fP at once to the same value. The default is a bold red text foreground over the current line background. .TP \fBms=01;31\fP SGR substring for matching non\-empty text in a selected line. (This is only used when the \fB\-v\fP command\-line option is omitted.) The effect of the \fBsl=\fP (or \fBcx=\fP if \fBrv\fP) capability remains active when this kicks in. The default is a bold red text foreground over the current line background. .TP \fBmc=01;31\fP SGR substring for matching non\-empty text in a context line. (This is only used when the \fB\-v\fP command\-line option is specified.) The effect of the \fBcx=\fP (or \fBsl=\fP if \fBrv\fP) capability remains active when this kicks in. The default is a bold red text foreground over the current line background. .TP \fBfn=35\fP SGR substring for file names prefixing any content line. The default is a magenta text foreground over the terminal's default background. .TP \fBln=32\fP SGR substring for line numbers prefixing any content line. The default is a green text foreground over the terminal's default background. .TP \fBbn=32\fP SGR substring for byte offsets prefixing any content line. The default is a green text foreground over the terminal's default background. .TP \fBse=36\fP SGR substring for separators that are inserted between selected line fields (\fB:\fP), between context line fields, (\fB\-\fP), and between groups of adjacent lines when nonzero context is specified (\fB\-\^\-\fP). The default is a cyan text foreground over the terminal's default background. .TP \fBne\fP Boolean value that prevents clearing to the end of line using Erase in Line (EL) to Right (\fB\e33[K\fP) each time a colorized item ends. This is needed on terminals on which EL is not supported. It is otherwise useful on terminals for which the \fBback_color_erase\fP (\fBbce\fP) boolean terminfo capability does not apply, when the chosen highlight colors do not affect the background, or when EL is too slow or causes too much flicker. The default is false (i.e., the capability is omitted). .PP Note that boolean capabilities have no \fB=\fP.\|.\|.\& part. They are omitted (i.e., false) by default and become true when specified. .PP See the Select Graphic Rendition (SGR) section in the documentation of the text terminal that is used for permitted values and their meaning as character attributes. These substring values are integers in decimal representation and can be concatenated with semicolons. \fBgrep\fP takes care of assembling the result into a complete SGR sequence (\fB\e33[\fP.\|.\|.\fBm\fP). Common values to concatenate include \fB1\fP for bold, \fB4\fP for underline, \fB5\fP for blink, \fB7\fP for inverse, \fB39\fP for default foreground color, \fB30\fP to \fB37\fP for foreground colors, \fB90\fP to \fB97\fP for 16\-color mode foreground colors, \fB38;5;0\fP to \fB38;5;255\fP for 88\-color and 256\-color modes foreground colors, \fB49\fP for default background color, \fB40\fP to \fB47\fP for background colors, \fB100\fP to \fB107\fP for 16\-color mode background colors, and \fB48;5;0\fP to \fB48;5;255\fP for 88\-color and 256\-color modes background colors. .RE .TP \fBLC_ALL\fP, \fBLC_COLLATE\fP, \fBLANG\fP These variables specify the locale for the \fBLC_COLLATE\fP category, which determines the collating sequence used to interpret range expressions like \fB[a\-z]\fP. .TP \fBLC_ALL\fP, \fBLC_CTYPE\fP, \fBLANG\fP These variables specify the locale for the \fBLC_CTYPE\fP category, which determines the type of characters, e.g., which characters are whitespace. This category also determines the character encoding, that is, whether text is encoded in UTF\-8, ASCII, or some other encoding. In the C or POSIX locale, all characters are encoded as a single byte and every byte is a valid character. .TP \fBLC_ALL\fP, \fBLC_MESSAGES\fP, \fBLANG\fP These variables specify the locale for the \fBLC_MESSAGES\fP category, which determines the language that \fBgrep\fP uses for messages. The default C locale uses American English messages. .TP \fBPOSIXLY_CORRECT\fP If set, \fBgrep\fP behaves as POSIX requires; otherwise, \fBgrep\fP behaves more like other GNU programs. POSIX requires that options that follow file names must be treated as file names; by default, such options are permuted to the front of the operand list and are treated as options. Also, POSIX requires that unrecognized options be diagnosed as \*(lqillegal\*(rq, but since they are not really against the law the default is to diagnose them as \*(lqinvalid\*(rq. . .SH NOTAS Esta página de manual no se mantienede forma rigurosa. La documentación completa suele estar más actualizada. . .SH COPYRIGHT Copyright 1998\-2000, 2002, 2005\-2023 Free Software Foundation, Inc. .PP Esto es software libre; consulte el código fuente para concoer las condiciones de distribución. NO existe garantía alguna; ni siquiera acerca de la COMERCIALIZACIÓN o la IDONEIDAD DE SU USO PARA UN FIN CONCRETO. . .SH ERRORES .SS "Informar de Errores" Email bug reports to .MT bug\-grep@gnu.org the bug\-reporting address .ME . An .UR https://lists.gnu.org/mailman/listinfo/bug\-grep email archive .UE and a .UR https://debbugs.gnu.org/cgi/pkgreport.cgi?package=grep bug tracker .UE are available. .SS "Errores Conocidos" Números de repetición grandes en la construcción \fB{\fP\fIn\fP\fB,\fP\fIm\fP\fB}\fP pueden hacer que \fBgrep\fP emplee grandes cantidades de memoria. En adición a esto, ciertas otras obscuras expresiones regulares requieren tiempo y espacio exponenciales, y pueden hacer que \fBgrep\fP se quede sin memoria. .PP Las retrorreferencias son muy lentas, y pueden requerir un tiempo exponencial. . .SH EJEMPLO The following example outputs the location and contents of any line containing \*(lqf\*(rq and ending in \*(lq.c\*(rq, within all files in the current directory whose names contain \*(lqg\*(rq and end in \*(lq.h\*(rq. The \fB\-n\fP option outputs line numbers, the \fB\-\-\fP argument treats expansions of \*(lq*g*.h\*(rq starting with \*(lq\-\*(rq as file names not options, and the empty file /dev/null causes file names to be output even if only one file name happens to be of the form \*(lq*g*.h\*(rq. .PP .in +2n .EX $ \fBgrep\fP \-n \-\- 'f.*\e.c$' *g*.h /dev/null argmatch.h:1:/* definiciones y prototipos para argmatch.c .EE .in .PP The only line that matches is line 1 of argmatch.h. Note that the regular expression syntax used in the pattern differs from the globbing syntax that the shell uses to match file names. . .SH "VÉASE TAMBIÉN" .SS "Páginas de Manual Genéricas" \fBawk\fP(1), \fBcmp\fP(1), \fBdiff\fP(1), \fBfind\fP(1), \fBperl\fP(1), \fBsed\fP(1), \fBsort\fP(1), \fBxargs\fP(1), \fBread\fP(2), \fBpcre2\fP(3), \fBpcre2syntax\fP(3), \fBpcre2pattern\fP(3), \fBterminfo\fP(5), \fBglob\fP(7), \fBregex\fP(7) .SS "Documentación Completa" A .UR https://www.gnu.org/software/grep/manual/ complete manual .UE is available. If the \fBinfo\fP and \fBgrep\fP programs are properly installed at your site, the command .IP \fBinfo grep\fP .PP debería acceder al manual completo. . .\" Work around problems with some troff -man implementations. .br . .\" Format for Emacs-maintained Dt string defined at this file's start. .\" Local variables: .\" time-stamp-format: "%:y-%02m-%02d" .\" End: .PP .SH TRADUCCIÓN La traducción al español de esta página del manual fue creada por Gerardo Aburruzaga García y Marcos Fouces . .PP Esta traducción es documentación libre; lea la .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 .UE o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD. .PP Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a .MT debian-l10n-spanish@lists.debian.org .ME .