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

141
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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