Comandos 'grep' y 'sed' equivalentes en Windows

Comandos 'grep' y 'sed' equivalentes en Windows

Estoy haciendo unas pruebas con un dominio que tengo, quiero que al hacer la consulta TXT reciba una cadena en base64 y la decodifique mostrando el mensaje.

En Linux funciona perfectamente:

$ dig -t txt my.domain.com +short | sed -e 's/^"//' -e 's/"$//' | base64 -d > file.txt
$ cat file.txt

probando mis registros de texto

Ahora quiero hacer lo mismo, excepto que en Windows, por defecto Windows no tiene dig, pero tiene un comando que es el siguiente:

C:\Users\User\xyz>powershell Resolve-DnsName my.domain.com -Type
TXT > test

C:\Users\Avell\xyz>type test

Name                                     Type   TTL   Section    Strings
----                                     ----   ---   -------    -------
my.domain.com                       TXT    10557 Answer    
{dGVzdGluZyBvdXQgbXkgdHh0IHJlY29yZHMK}

¿Cómo podría adaptar el comando anterior (Linux) para que funcione en Windows, tomando solo el agitado en base64 y decodificando para mostrar el mensaje?

Respuesta1

O dedique el tiempo necesario a aprender PowerShell, aprovechando todos los recursos y videos gratuitos en Youtube para comprender todas las partes de PowerShell, qué se puede hacer de forma nativa y cuándo necesita codificarlo usted mismo y cuándo necesita utilizar herramientas 3rdP. .

No es la primera vez que se pregunta esto. Una búsqueda rápida en la web utilizando 'PowerShell Sed' y 'PowerShell Grep' le mostrará una buena lista de estos e incluso ejemplos.

Get-Content Obtiene el contenido del elemento en la ubicación especificada.

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-content?view=powershell-7

Select-String Busca texto en cadenas y archivos.

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/select-string?view=powershell-7

sed en PowerShell

https://docs.microsoft.com/en-us/archive/blogs/sergey_babkins_blog/sed-in-powershell

PowerShell – Equivalente a UNIX SED – Cambiar texto en archivo

https://www.kittell.net/code/powershell-unix-sed-equivalent-change-text-file

Usando sed y grep en PowerShell

https://www.catapultsystems.com/blogs/using-sed-and-grep-in-powershell

http://www.systemcentercentral.com/using-sed-and-grep-in-powershell

Grep, al estilo PowerShell

https://communary.net/2014/11/10/grep-the-powershell-way

Cómo "grep" en PowerShell

https://antjanus.com/blog/web-development-tutorials/how-to-grep-in-powershell

Cómo hacer grep en PowerShell

https://www.adamfowlerit.com/2017/02/how-to-grep-in-powershell

Consejo rápido: equivalente a PowerShell Grep

https://dereknewton.com/2010/12/powershell-grep-equivalent

POWERSHELL: BÚSQUEDA DE STRING O GREP PARA POWERSHELL

https://www.thomasmaurer.ch/2011/03/powershell-search-for-string-or-grep-for-powershell

En segundo lugar, aprovechar laGalería de Microsoft powershelldirectamente en su consola PowerShell o en la nueva Terminal de Windows...

Find-Module -Name '*grep*' | Format-Table -AutoSize

Version Name     Repository Description                 
------- ----     ---------- -----------                 
1.1.0   PoshGrep PSGallery  Greplike PowerShell function



 Find-Package -Name '*grep*' | Format-Table -AutoSize

Name      Version        Source    Summary                                                                
----      -------        ------    -------                                                                
wk.Grep   0.2.0          nuget.org Package Description                                                    
Liv.Grep  1.0.5436.17982 nuget.org Grep utility written in c#. Makes it easy to query command line outputs
AstroGrep 4.3.2          nuget.org This application and its source code are freely distributable.         
GRepo     1.0.0          nuget.org GRepo                                                                  
PoshGrep  1.1.0          PSGallery Greplike PowerShell function

... o cuando se utilizan editores de PowerShell, que proporcionan ayuda emergente/IntelliSense (PowerShell_ISE integrado,Descarga de código VS,PowerShell Plusque son gratuitos) o (Estudio PowerShell de Sapien- cuesta dinero.)

Por último, también estás utilizando excavar en tu código. Para eso vea esto:

PowerShell: consulte el servidor DNS para registros A, PTR, MX, NS y otros

Cómo utilizar PowerShell para registros DNS

información relacionada