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

142
Vistas
Interpret a string with escape characters from stdin

if I have a file like:

hello \n world

how can I print the contents of the file with the escape sequences interpreted, so in the terminal you see:

hello 
 world

I've tried cat file | xargs -I{} echo {} but that prints hello n world

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

0

printf's %b format specifier expands escape sequences:

$ printf '%b\n' "$(cat file)"
hello
 world

To read from stdin an unadorned cat will do:

$ printf '%b\n' "$(cat)"
hello
 world
over 4 years ago · Santiago Trujillo Denunciar

0

I think

echo 'hello\\nworld' | xargs -I {} printf "%b" "{}"

is what you're after. But that requires you to have some control over the text sent over the pipe since it requires double backslashes.

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