`sed -i "s/^image:.*/image: $IMAGE/" deploy.yaml` fails with `sed: -e expression #1, char 32: unknown option to `s'`
IntermediateTroubleshootingTroubleshooting: quoting, expansion and tool-input bugs
Answer
Likely causes → $IMAGE contains / (ghcr.io/acme/api:1.4.2), which ends the s command early; sed then reads the rest as flags.
Diagnose → echo "s/^image:.*/image: $IMAGE/" shows the extra slashes.
Fix → Use a delimiter that cannot appear in the value, and escape & and \ in replacements:
sed -i "s|^\( *image:\).*|\1 ${IMAGE}|" deploy.yaml
Better for YAML: IMAGE=$IMAGE yq -i '.spec.template.spec.containers[0].image = strenv(IMAGE)' deploy.yaml.
Prevent → Use structural tools for structured files; escape values when sed is unavoidable.
More on Troubleshooting: quoting, expansion and tool-input bugs
`bash: [: too many arguments`Beginner`bash: [: =: unary operator expected`BeginnerA disk check fails with `[: 93%: integer expression expected`Beginner`rm $file` fails with `rm: cannot remove 'monthly': No such file or directory` and `rm: cannot remove 'report.csv'`.BeginnerA cleanup script logs `cp: cannot stat '/var/log/app/*.log': No such file or directory` on quiet days.Beginner`echo "start" > $logfile` fails with `bash: $logfile: ambiguous redirect`Intermediate