Возникла задача: в командной строке/скрипте bash после каждого символа строки, (желательно: кроме последнего), добавить "~?". Например,
было "12345"
стало "1~?2~?3~?4~?5"
$ bash --version
GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ echo ${${"$(<<< 12345)"///~?}[3,-1]}
-bash: ${${"$(<<< 12345)"///~?}[3,-1]}: bad substitution
$ bash --version
GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ echo ${${"$(<<< 12345)"///~?}[3,-1]}
-bash: ${${"$(<<< 12345)"///~?}[3,-1]}: bad substitution
У Вас какие-то хитрые надстройки?
Вероятно, имелась ввиду только та часть, где используется замена. Попробуйте echo${PWD///~?}.