Strings In Depth9 / 17
Up next

Replace first match

#!/usr/bin/env bash
s="a-b-c"
# ${var/pattern/replacement} replaces only the first match
echo "${s/-/_}"
What you're solving

${s/old/new} replaces the first occurrence