¿Hay una utilidad de Coincidencia de patrones como GREP en Windows?


¿Hay una utilidad similar a grep disponible desde el símbolo del sistema de Windows, o hay una herramienta de terceros para ella?

 141
Author: Roman C, 2009-09-13

29 answers

Hay una herramienta de línea de comandos llamada FINDSTR que viene con todos los sistemas operativos de clase NT de Windows (escriba FINDSTR /? en una ventana del símbolo del sistema para obtener más información) No admite todo lo que grep hace, pero podría ser suficiente para sus necesidades.

 199
Author: Ken Keenan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-09-12 21:51:29

PowerShell (incluido como estándar en Windows 7/2008R2, opcional para XP/2003/Vista/2008) que incluye el cmdlet select-string para este propósito.

 32
Author: Richard,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-09-13 07:28:16

Grep para Windows por GnuWin Project (2014-10-02: Está desactualizado, ver comentarios a continuación)

 32
Author: Gregor,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-10-02 12:15:46

Como se mencionó, findstr funciona bien. ejemplo :

C: > dir | findstr Windows

11/06/2013 09: 55 PM Windows

 21
Author: Parallel Universe,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-12-30 20:07:57

También encontré una forma más de utilizar GREP como funcionalidad en Windows 7 y superiores sin ninguna aplicación adicional para instalar y en sistemas más antiguos se puede utilizar instalar Powershell.

En Powershell, el Usuario puede usar Donde-Object tiene un conjunto bastante completo de características que proporciona toda la funcionalidad de GREP y más.

Espero Que ayude.

 11
Author: Chintan Shah,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-07-31 01:13:35

Me sorprende que nadie haya mencionado FINDSTR. No soy un poweruser de grep, pero findstr hace lo que necesito, filtrar archivos y stdin, con algún soporte de expresiones regulares primitivas. Barcos con ventanas y todo eso. (Editar: Bueno, alguien mencionó findstr, Es tarde, supongo)

 10
Author: Svend,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-09-13 02:24:18

Cygwin grep y más ;)

 9
Author: sdu,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-09-12 22:36:06

GnuWin32 vale la pena mencionar, proporciona la versión nativa de Win32 de todas las herramientas estándar de linux, incluyendo grep, file, sed, groff, indent, etc.

Y se actualiza constantemente cuando se lanzan nuevas versiones de estas herramientas.

 6
Author: Diaa Sami,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-09-13 02:16:36

En Windows utilizo Far Manager para la búsqueda de archivos. Licencia BSD, funciona en consola, ahorra tiempo al escribir parámetros cmdline. Aquí está su diálogo de búsqueda invocado por Alt-F7. Alt-F7

 4
Author: anatoly techtonik,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-04-21 09:26:23

UnxUtils es un gran conjunto de utilidades Unix que se ejecutan en Windows. Tiene grep, sed, gawk, etc.

 3
Author: Andy White,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-09-12 22:03:01

Una utilidad de búsqueda de archivos excelente y muy rápida, Agent Ransack, admite la búsqueda de expresiones regulares. Es principalmente una utilidad GUI, pero una interfaz de línea de comandos también está disponible.

 3
Author: JPaget,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-12-06 19:26:38

Actualización: Esto no era cierto cuando se hizo la pregunta originalmente, pero ahora Microsoft permite a uno Instalar el Subsistema de Windows para Linux, y Windows ejecutará grep. En PowerShell, ejecute:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
 3
Author: woodvi,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-05 20:58:04

En el reskit de Windows hay una utilidad llamada "qgrep". Puede que ya lo tengas en tu caja. ;- ) También viene con el comando "cola", gracias a Dios!

 2
Author: Jubal,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-09-13 04:06:40

Aunque técnicamente no grep ni línea de comandos, tanto Microsoft Visual Studio como Notepad++ tienen una muy buena función Find in Files con soporte completo de expresiones regulares. Me encuentro usándolos con frecuencia a pesar de que también tengo la versión CygWin de grep disponible en la línea de comandos.

 1
Author: GBegen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-09-14 21:58:03

Agregaré mis $0.02 a este hilo. dnGREP es una gran herramienta grep de código abierto para Windows que admite deshacer, integración con el explorador de Windows, búsqueda dentro de archivos PDF, cremalleras, documentos y un montón de otras cosas...

 1
Author: stankovski,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-05-17 18:35:27

Sí, solo hay un programa para PC con Windows que tiene GUI sólida y es útil esencial para mí. Trabajo como desarrollador y en cada computadora que he tenido, lo primero que instalo es el programa xFind. Se creó en 1997 y hasta ahora la versión es 1.0 y hasta ahora funciona y es el mejor. Con frecuencia necesito buscar alguna cadena en un ".cs", " .aspx", " .sct "(Visual FoxPro form code file)o simplemente " .* "y xFind escanea todos los archivos y me muestran los archivos y otra gran cosa es que usted puede buscar dónde está string en el archivo. xFind también tiene algún tipo de editor. Si es un archivo binario, le mostrará la cadena finded. Pruébalo y úsalo para siempre si eres desarrollador como yo.

 1
Author: Shixx,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-10-13 14:07:56

Obviamente has recibido muchas recomendaciones diferentes.
Mi elección personal para una Utilidad Gratuita de 3rd Party es: Agente Ransack
Agente Ransack Descargar
A pesar de su nombre algo confuso, funciona bien y se puede utilizar en una variedad de maneras de encontrar archivos.

Buena suerte

 1
Author: Dhugalmac,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-10-16 19:42:53

Si instala Cygwin o Mingw, entonces sí.

De lo contrario, no que yo sepa.

 0
Author: Jonathan Leffler,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-09-12 21:50:07

Bare Grep es bueno si quieres una GUI. Gnu grep es bueno para CLI

 0
Author: Ariel,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-09-12 22:11:37

Si no te importa un producto de pago, PowerGREP es mi favorito personal.

 0
Author: David Andres,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-09-12 22:13:46

Recientemente hemos usado PowerGREP para algunas operaciones masivas bastante avanzadas en miles de archivos. Incluyendo búsqueda regex en el contenido de archivos PDF, y la alteración de documentos PDF en gran escala.

Vale la pena el dinero si quieres ahorrar tiempo de manuel labor. Puedes probarlo antes de comprar, creo.

 0
Author: Lars Udengaard,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-09-12 22:32:22

Si tiene que usar Windows desnudo, además de la opción de Powershell mencionada anteriormente, puede usar VBScript, que admite expresiones regulares decentes.

MS también tiene un área de scripting decente en Technet con un montón de ejemplos para administradores.

 0
Author: Ron Ruble,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-09-13 01:29:02

Simplemente pruebe la utilidad java LikeGrep. Puede ayudarle en muchos casos. Como desee, también puede reemplazar algo de texto, que se encuentra en los archivos. Garantiza su trabajo en archivos grandes (hasta 8 Gb probados)

 0
Author: Igor,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-02-04 16:13:40

Como se mencionó anteriormente, el proyecto gnuwin32 tiene una versión para Windows CLI de grep.

Si quieres algo con una interfaz gráfica, te recomendaría la herramienta (de código abierto) AstroGrep.

 0
Author: bta,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-02-04 16:20:52

Ha pasado un tiempo desde que los he usado, pero Borland (Embarcadero ahora) incluyó un grep de línea de comandos con su compilador C/C++. Durante algún tiempo, han puesto a disposición su versión 5.5 como una descarga gratuita después de registrarse.

 0
Author: GreenMatt,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-02-04 16:34:04

Hay una utilidad grep comercial disponible en Oak Road Systems.

 0
Author: JPaget,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-12-06 19:22:16

Recomiendo PowerGrep

Tuve que hacer un proyecto de e-discovery hace varios años. Descubrí que fisdstr tenía algunas limitaciones, más especialmente fisdstr finalmente fallaría

El script tuvo que buscar en miles de archivos usando un par de docenas de términos/frases de búsqueda.

El grep de Cygwin funcionó mucho mejor, no se ahogó a menudo, pero finalmente fui a PowerGREP porque la interfaz gráfica hizo que fuera mucho más fácil saber cuándo y donde se estrelló, y también fue muy fácil de editar en todos los condicionales y salida que quería. Finalmente PowerGREP fue el más confiable de los tres.

 0
Author: Haggisbreath,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-03-24 07:17:23

El busybox todo en uno contiene grep / egrep / sed / awk y muchos más

Obtenerlo de:

O algo más antiguo

 0
Author: Bernhard,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-01-19 10:21:50

Sé que es un tema un poco viejo, pero aquí hay otra cosa que puedes hacer. Trabajo en una VM de desarrollador sin acceso a Internet y espacio libre en disco bastante limitado, así que hice uso de Java instalado en ella.

Compilar un pequeño programa java que imprime coincidencias regex a la consola. Coloque el jar en algún lugar de su sistema, cree un lote para ejecutarlo y agregue la carpeta a su variable PATH:

JGrep.java:

package com.jgrep;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class JGrep {

    public static void main(String[] args) throws FileNotFoundException, IOException {
        int printGroup = -1;
        if (args.length < 2) {
            System.out.println("Invalid arguments. Usage:");
            System.out.println("jgrep [...-MODIFIERS] [PATTERN] [FILENAME]");
            System.out.println("Available modifiers:");
            System.out.println(" -printGroup            - will print the given group only instead of the whole match. Eg: -printGroup=1");
            System.out.println("Current arguments:");
            for (int i = 0; i < args.length; i++) {
                System.out.println("args[" + i + "]=" + args[i]);
            }
            return;
        }
        Pattern pattern = null;
        String filename = args[args.length - 1];
        String patternArg = args[args.length - 2];        
        pattern = Pattern.compile(patternArg);

        int argCount = 2;
        while (args.length - argCount - 1 >= 0) {
            String arg = args[args.length - argCount - 1];
            argCount++;
            if (arg.startsWith("-printGroup=")) {
                printGroup = Integer.parseInt(arg.substring("-printGroup=".length()));
            }
        }
        StringBuilder sb = new StringBuilder();
        try (BufferedReader br = new BufferedReader(new FileReader(filename))) {
            sb = new StringBuilder();
            String line = br.readLine();

            while (line != null) {
                sb.append(line);
                sb.append(System.lineSeparator());
                line = br.readLine();
            }
        }
        Matcher matcher = pattern.matcher(sb.toString());
        int matchesCount = 0;
        while (matcher.find()) {
            if (printGroup > 0) {
                System.out.println(matcher.group(printGroup));
            } else {
                System.out.println(matcher.group());
            }
            matchesCount++;
        }
        System.out.println("----------------------------------------");
        System.out.println("File: " + filename);
        System.out.println("Pattern: " + pattern.pattern());
        System.out.println("PrintGroup: " + printGroup);
        System.out.println("Matches: " + matchesCount);
    }
}

C:\jgrep\jgrep.bat (junto con jgrep.jar):

@echo off
java -cp c:\jgrep\jgrep.jar com.jgrep.JGrep %*

Y añadir c:\jgrep al final de la variable de entorno PATH.

Ahora simplemente llama a jgrep "expression" file.txt desde cualquier lugar.

Necesitaba imprimir algunos grupos específicos de mi expresión, así que agregué un modificador y lo llamé como jgrep -printGroup=1 "expression" file.txt.

 0
Author: mihail,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-01-29 16:09:38