code example:my PWD = /aa/bb/cc/dd
dir= `dirname "$(PWD)"`
output = `basename "${dir}"`dir variable outputs correctly: /aa/bb/cc
desired output variable: cc
error I'm getting: /bin/sh: 1: Syntax error: Unterminated quoted string
I've tried different quotation combinations and other things like these suggested solutions: and
42 Answers
Below code is working for me :
dir1=`dirname "$PWD"`
output=`basename "$dir1"` 1 Instead of "$(PWD)", you'll want "${PWD}". The former tries to execute the command PWD, the latter expands to the value of the variable PWD.