0

I run nano test.txt

Hello $NAME

then export NAME="World"


  • Then I run envsubst < text.txt it prints Hello World

  • Then I run envsubst < text.txt > new.txt it saves Hello World into new.txt

  • Then I run envsubst < text.txt > text.txt but when open text.txt but it is an empty file

How can I replace the file with envsubst?

Cyrus
  • 84,225
  • 14
  • 89
  • 153
Amin Ba
  • 1,603
  • 1
  • 13
  • 38
  • `envsubst < text.txt | sponge text.txt`? See `man sponge`. You may need to install `sponge` first. – Cyrus May 09 '22 at 20:41
  • This question is unrelated to `envsubst`, but a general problem with redirection. You would observe the same effect with, i.e., `tr` or `sed`. – user1934428 May 10 '22 at 06:53

0 Answers0