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

261
Vistas
transform stream sent to a file by tee

I want to redirect the stdout and stderr of a stream both to the screen and a file. For that I'm using the tool tee. However, before that stream goes to the file, I want to transform it using a pipe. So far, I have only managed to transform the stream that goes to stdout.

Example:

echo 'hello' | tee output.txt | tr 'h' 'e'

=> this will output eello to stdout and save hello to output.txt

However what I want is to print hello to stdout and save eello to output.txt.

Note: Changing the input stream is not an option for my problem.

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

0

With bash:

echo 'hello' | tee >(tr 'h' 'e' > output.txt)

With bash and Linux:

echo 'hello' | tee /proc/$$/fd/255 | tr 'h' 'e' > output.txt

See: What is the use of file descriptor 255 in bash process

over 4 years ago · Santiago Trujillo Denunciar

0

You can do that in a single awk without multiple pipes:

echo 'hello' | awk '1; {gsub(/h/, "e"); print > "output.txt"}'
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