Clare
Clare

Reputation: 5

'Bad substitution' error in bash script

I keep getting a 'bad substitution' error in my bash script at the point ${basename $option} where '$option' is input later in the script, does anyone know how to fix it?

function findByExtension {
strip=${basename $option}
extension="${strip##*.}"

}

I have also included '#!/bin/bash' at the start of the script.

Upvotes: 0

Views: 2516

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798646

You want to perform command substitution there, not parameter substitution.

strip="$(basename "$option")"

Upvotes: 2

Related Questions