I have the following function split in my .bash_profile file.function split {   name=${$1%.*}   ext=${$1##*.}   echo filename=$name extension=$ext}Now I should expect that the command split foo.bar will give me filename=foo  extension=barBut I get get -bash: ${$1%.*}: bad substitution error message. The same however works for usual shell variable in a shell script, say $x instead of $1 in .bash_profile (I think the same goes in .bashrc as well). What's wrong and any remedy?
bash function : splitting name and extension of a file
bash;function
Drop the $ preceding the variable name (1) inside the parameter expansion:name=${1%.*}ext=${1##*.}you are already referring to the variable with the $ preceding the starting brace {, no need for another one in front of the variable name.