Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda