Ao usar este site, você concorda com o política de Privacidade.
Aceitar
Entrar em TIEntrar em TIEntrar em TI
  • LAR
  • PROFISSIONAL DE TI
  • TECNOLOGIA
  • Microsoft
    • Azul
    • ConfigMgr/SCCM
    • PMD
    • Orquestrador
    • Hiper-V
    • Microsoft Edge Insider
    • MSI
    • Escritório 365
    • Office Insider
    • Power BI
    • Skype
    • Servidor SQL
    • Equipes
  • WINDOWS
    • Centro de Administração do Windows
    • Cliente Windows
    • Servidor Windows
  • Lista de coleta de consultas SCCM
Leitura: PowerShell extract strings from a file
Redimensionador de fontesAh
Entrar em TIEntrar em TI
Redimensionador de fontesAh
  • LAR
  • PROFISSIONAL DE TI
  • TECNOLOGIA
  • Microsoft
  • WINDOWS
  • Lista de coleta de consultas SCCM
Procurar
  • LAR
  • PROFISSIONAL DE TI
  • TECNOLOGIA
  • Microsoft
    • Azul
    • ConfigMgr/SCCM
    • PMD
    • Orquestrador
    • Hiper-V
    • Microsoft Edge Insider
    • MSI
    • Escritório 365
    • Office Insider
    • Power BI
    • Skype
    • Servidor SQL
    • Equipes
  • WINDOWS
    • Centro de Administração do Windows
    • Cliente Windows
    • Servidor Windows
  • Lista de coleta de consultas SCCM
PowerShell

PowerShell extract strings from a file

Published April 25, 2024
1 Leitura mínima
COMPARTILHAR

PowerShell extract strings from a file.

To extract only strings from a file using PowerShell, you can use the Select-String cmdlet.

Here’s an example command to extract strings from a file:

Get-Content path/to/file.txt | Select-String -Pattern '\b\w+\b'

Neste exemplo, path/to/file.txt is the path to the file you want to extract strings from. O Get-Content cmdlet reads the file and outputs its content as an array of strings. O Select-String cmdlet then searches for strings that match the regular expression pattern \b\w+\b, which matches any word character (letters, dígitos, and underscores) surrounded by word boundaries. The output of the Select-String cmdlet is a collection of MatchInfo objects that contain the matching strings.

If you want to output just the matching strings (without the MatchInfo objects), you can pipe the output to the ForEach-Object cmdlet and use the $_.Matches.Value property to extract the matching strings, like this:

Get-Content path/to/file.txt | Select-String -Pattern '\b\w+\b' | ForEach-Object { $_.Matches.Value }

This will output only the matching strings from the file.

MARCADO:PowerShellWindowsWindows 10Servidor Windows 2016Servidor Windows 2019Windows Terminal
Artigo Anterior Lista de coleta de consultas do Configuration Manager Lista de coleta de consultas do Configuration Manager
Próximo artigo Command Line Tips: Checking TLS/SSL Certificate Expiration Dates
Deixe um comentário Deixe um comentário

Deixe uma resposta Cancelar resposta

Seu endereço de e-mail não será publicado. Os campos obrigatórios estão marcados *

Este site usa Akismet para reduzir spam. Saiba como os dados dos seus comentários são processados.

Tradução

English中文(简体)DanskNederlandsFrançaisDeutschItaliano한국어PolskiPortuguêsRomânăEspañolУкраїнська
 Editar tradução
por Transposh - translation plugin for wordpress

Postagens populares

Requisitos do sistema para Windows Server 2016
Servidor Windows
Lista de coleta de consultas do Configuration Manager
Lista de coleta de consultas do Configuration Manager
ConfigMgr
Navegação estruturada/gerenciada habilitada em páginas modernas em sites de equipe clássicos
Tecnologia
SCCM Falha ao obter locais de DP como a versão esperada do MP
ConfigMgr

Postagens recentes

Instalando e configurando Fail2ban para proteção SSH no Ubuntu 24.04
Linux
Habilitando e configurando FirewallD no AlmaLinux
Linux
Criação de usuário e configuração de chave SSH no AlmaLinux
Linux
Como redefinir a senha no AlmaLinux
Linux

© 2023 Entrar em TI

Vá para a versão móvel
banner
Bem vindo de volta!

Faça login na sua conta

Nome de usuário ou endereço de e-mail
Senha

Perdeu sua senha?