Command using both redirection and pipes truncates file

Solution Verified - Updated -


  • When using the same file as both the input and the output for a BASH command, the file is truncated unexpectedly.
  • The following command truncates certain files, why is that?

    find /opt/app-root/src -type f -exec bash -c 'envsubst \${MY_VARIABLE} < $1 | tee $1'
  • After using tee on a file, the file is seemingly cut and no longer complete


  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux CoreOS (RHCOS)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In