Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

157
Visualizações
sed unintentionally wipes remainder of line

Attempting to locate a variety of similar incidents within a file.

<address DOMAIN='0x000' bus='PCOIP_USB0' slot='0x00' function '0x0' />
<address DOMAIN='0x000' bus='PCOIP_USB1' slot='0x00' function '0x0' />
<address DOMAIN='0x000' bus='PCOIP_USB7' slot='0x00' function '0x0' />
<address type='bmu' domain='0x000' bus='PCOIP_USB9' slot='0x00' function '0x0' />
<address DOMAIN='0x000' bus='PCOIP_USB4' slot='0x00' function '0x0' />

I'm attempting to simply locate any instance beginning with PCOIP_ and replace that string with 0x86

The result will look like:

<address DOMAIN='0x000' bus='0x86' slot='0x00' function '0x0' />
<address DOMAIN='0x000' bus='0x86' slot='0x00' function '0x0' />
<address DOMAIN='0x000' bus='0x86' slot='0x00' function '0x0' />
<address type='bmu' domain='0x000' bus='0x86' slot='0x00' function '0x0' />
<address DOMAIN='0x000' bus='0x86' slot='0x00' function '0x0' />

The command I'm trying currently which handles replacing the necessary string, except it also wipes the remainder of that entire line:

sed s/PCOIP_\(.*\)/0x86/g' file

The command as is makes the file look like:

<address DOMAIN='0x000' bus='0x86
<address DOMAIN='0x000' bus='0x86
<address DOMAIN='0x000' bus='0x86
<address type='bmu' domain='0x000' bus='0x86
<address DOMAIN='0x000' bus='0x86
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can use

sed "s/PCOIP_[^']*/0x86/g" file

Here, PCOIP_[^']* matches PCOIP_ and then any zero or more chars other than a ' char. The whole match is replaced with 0x86 substring.

See an online demo:

#!/bin/bash
s="<address DOMAIN='0x000' bus='PCOIP_USB0' slot='0x00' function '0x0' />
<address DOMAIN='0x000' bus='PCOIP_USB1' slot='0x00' function '0x0' />
<address DOMAIN='0x000' bus='PCOIP_USB7' slot='0x00' function '0x0' />
<address type='bmu' domain='0x000' bus='PCOIP_USB9' slot='0x00' function '0x0' />
<address DOMAIN='0x000' bus='PCOIP_USB4' slot='0x00' function '0x0' />"
sed "s/PCOIP_[^']*/0x86/g" <<< "$s"

Output:

<address DOMAIN='0x000' bus='0x86' slot='0x00' function '0x0' />
<address DOMAIN='0x000' bus='0x86' slot='0x00' function '0x0' />
<address DOMAIN='0x000' bus='0x86' slot='0x00' function '0x0' />
<address type='bmu' domain='0x000' bus='0x86' slot='0x00' function '0x0' />
<address DOMAIN='0x000' bus='0x86' slot='0x00' function '0x0' />
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda