Article 59GTN [SOLVED] Bash script - bad substitution

[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 substitutionlatest?d=yIl2AUoC8zA latest?i=Y2HlZe83Gfw:vQaYN8JEBQA:F7zBnMy latest?i=Y2HlZe83Gfw:vQaYN8JEBQA:V_sGLiP latest?d=qj6IDK7rITs latest?i=Y2HlZe83Gfw:vQaYN8JEBQA:gIN9vFwY2HlZe83Gfw
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments