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=bar
But 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?
echocommand. – Wildcard Sep 28 '16 at 20:09nameandextas already pointed out by @SatoKatsura. – hbaromega Sep 28 '16 at 21:40