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

190
Vistas
sed: Getting Two Extra Characters in the Results

How can I display the next two characters from sed results (wildcard characters and then stop the results)?

echo 'this is a test line' | sed 's/^.*te*/te../'

Expecting test

Actual results te.. line

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You can use

sed -n 's/.*\(te..\).*/\1/p' <<< 'this is a test line'

See the online demo. Here,

  • -n - suppresses the default line output
  • .*\(te..\).* - matches any zero or more chars, then captured into Group 1 te and any two chars, and then matches the rest of the string
  • \1 - replaces the whole match with the value of Group 1
  • p - only prints the result of the substitution.
over 4 years ago · Santiago Trujillo Denunciar

0

GNU AWK solution

echo 'this is a test line' | awk 'BEGIN{FPAT="te.."}{print $1}'

output

test

Explanation: Inform AWK to detect fields like te.. using FPAT (Field PATtern) then just print 1st field.

(tested in GNU Awk 5.0.1)

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