[SOLVED] Bash script - bad substitution
by GPGAgent from LinuxQuestions.org on (#59GTN)
Hi Folks, This is syntax problem not been able to ddg it so here goes:Code:X=$0 # save $0 in a local variable
Y=${0##*/} # remove dir part
Z=${Y%.*} # remove extension - if you want to do so
echo "X=\$0:$X Y=\${0##*/} :$Y Z=\${Y%.*}:$Z"and you run it it gives this:Code:X=$0:./DVDOpts.sh Y=${0##*/} :DVDOpts.sh Z=${Y%.*}:DVDOpts
${0##*/}:DVDOpts.shHow can I avoid using the intermediate variable Y?
I tried this:Code:echo "\${0##*/}:${0##*/} ${{0##*/}%.*} "which gave the ereror message:Code:./DVDOpts.sh: line 21: \${0##*/}:${0##*/} ${{0##*/}%.*} : bad substitution


Y=${0##*/} # remove dir part
Z=${Y%.*} # remove extension - if you want to do so
echo "X=\$0:$X Y=\${0##*/} :$Y Z=\${Y%.*}:$Z"and you run it it gives this:Code:X=$0:./DVDOpts.sh Y=${0##*/} :DVDOpts.sh Z=${Y%.*}:DVDOpts
${0##*/}:DVDOpts.shHow can I avoid using the intermediate variable Y?
I tried this:Code:echo "\${0##*/}:${0##*/} ${{0##*/}%.*} "which gave the ereror message:Code:./DVDOpts.sh: line 21: \${0##*/}:${0##*/} ${{0##*/}%.*} : bad substitution