bash - Conditional Parameter Substitution while using cat -


i'm using cat create file environment variable.

cat <<eof > config environment = ${environment:-dev} eof 

i need dev, if development or develop. cannot trim because, has other possible values qa, demo, staging etc.

please note: cannot use if statement, in environment. used in jenkins execute shell, have parameterized build, using if require me repeat above cat, multiple times

any easy way guys..

regards, shan

try this:

cat <<eof > config   environment = $([[ "${environment}" =~ ^dev ]] && environment=dev && echo $environment) eof 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -