nginx: use environment variables

With NGINX Docker image Apply envsubst on template of the configuration file at container start. envsubst is included in official NGINX docker images. Environment variable is referenced in a form $VARIABLE or ${VARIABLE}. nginx.conf.template: user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { server { listen 80; location … Read more

Remove part of path on Unix

If you wanted to remove a certain NUMBER of path components, you should use cut with -d”https://stackoverflow.com/”. For example, if path=/home/dude/some/deepish/dir: To remove the first two components: # (Add 2 to the number of components to remove to get the value to pass to -f) echo $path | cut -d”https://stackoverflow.com/” -f4- # output: # some/deepish/dir … Read more

Can I call a function of a shell script from another shell script?

Refactor your second.sh script like this: func1 { fun=”$1″ book=”$2″ printf “func=%s,book=%s\n” “$fun” “$book” } func2 { fun2=”$1″ book2=”$2″ printf “func2=%s,book2=%s\n” “$fun2” “$book2” } And then call these functions from script first.sh like this: source ./second.sh func1 love horror func2 ball mystery OUTPUT: func=love,book=horror func2=ball,book2=mystery

Block Comments in a Shell Script

In bash: #!/bin/bash echo before comment : <<‘END’ bla bla blurfl END echo after comment The ‘ and ‘ around the END delimiter are important, otherwise things inside the block like for example $(command) will be parsed and executed. For an explanation, see this and this question.