Automation, Orchestration, and Scripting
A script stores file=/backups/db_2024.tar.gz. The script needs only the file name, db_2024.tar.gz, with the directory portion removed. Which expansion produces it?
Show the answer
Correct answerC. ${file##*/}
The ## operator removes the longest prefix matching */, leaving the text after the last slash. The single # form is tempting but removes only the shortest match, which is the leading slash, leaving backups/db_2024.tar.gz.