echo ${VAR/old/new}

Category: Shell & Bash

echo ${VAR/old/new}

Replace first occurrence in variable value

Replaces only the first occurrence of 'old' with 'new' within a variable's value.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.