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
Post a Comment