i have config file contains env_variable styled variables.
this file. might contain $examples of text.
now want variable replaced value saved in actual environment variables. i'm trying this:
export examples=lots envsubst < file.txt > file.txt
but doesn't work when input file , output file identical. result empty file of size 0.
there must reason this, bash basics i'm not aware of? how achieve want do, ideally without first outputting different file , replacing original file it?
i know can enough sed
, when discovered envsubst
command thought should perfect use case, i'd use that.
redirects handled shell, not program being executed, , setup before program invoked.
the redirect >output.file
has effect of creating output.file
if doedn't exist , emptying if does. either way, end empty file, , program's output redirected to.
programs sed
capable of "in-place" modification must take filename command-line argument, not redirect.
in case, suggest using temporary file , renaming if went ok.
Comments
Post a Comment