Replace and Trim in Variables
${var/old/new} replaces, ${var#pat} removes a prefix and ${var%pat} removes a suffix.
Example
f="report.final.txt"
echo "${f/final/draft}"
echo "${f%.txt}"
echo "${f#*.}"
echo "${f##*.}"
echo "${f^^}"Result
report.draft.txt report.final final.txt txt REPORT.FINAL.TXT
Exercise
Remove a suffix.
${f.txt}
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.