I am trying the following in a bash script on Linux:
envA="prdk8s--staging-a"
envB="prd-k8s--sandbox"
for envCode in $envA $envB;
do
Code=$(echo $envCode | cut -d "--" -f 1)
echo $Code
done
However, this fails:
cut: the delimiter must be a single character
Try 'cut --help' for more information.
Expected output:
staging
sandbox
Is there a way to print the next word after "--" in the variable values $envA and $envB?