Difference between shell and environment variables

Citing this source, Standard UNIX variables are split into two categories, environment variables and shell variables. In broad terms, shell variables apply only to the current instance of the shell and are used to set short-term working conditions; environment variables have a farther reaching significance, and those set at login are valid for the duration …

Read more

Referencing Environment Variables in web.xml

You can use Ant-style variable substitution in any of the tomcat xml config files, such as: <servlet-mapping> <servlet-name>mvc-dispatcher</servlet-name> <url-pattern>${foo}</url-pattern> </servlet-mapping> Where foo is a Java System Property (sysprop). You can’t use OS Environment Variables (envvars) directly, I think… To use envvars, you can put set “CATALINA_OPTS=-DsomeJavaSysProp=%SOME_OS_ENVVAR%” in bin/setenv.bat (or similarly in bin/setenv.sh for *nix). You …

Read more

Can envsubst not do in-place substitution?

Here is the solution that I use: originalfile=”file.txt” tmpfile=$(mktemp) cp –attributes-only –preserve $originalfile $tmpfile cat $originalfile | envsubst > $tmpfile && mv $tmpfile $originalfile Be careful with other solutions that do not use a temporary file. Pipes are asynchronous, so the file will occasionally be read after it has already been truncated.