Thanks for that, it's an interesting idea and I'll have to add 'sed' to my many things to learn about Linux!
Unfortunately, it doesn't quite give me the result I wanted and after re-reading my initial post (and cursing at my English errors) I decided I wasn't clear enough.
Your solution has a hardcoded $HOME in the string (perhaps $HOME was a bad example), however, the string I've just extracted and stored in a variable contains (say):-
where DIRVAR has been setup globally. Basically, the DIRVAR would contain another directory path which would be used as some sort of system release i.e "beta_release/1a" or "/issue_release/2a" etc...
I've passed the read in string to a subroutine. If I then 'echo' $1 from within my bash script, that is exactly what I get (without $DIRVAR expanded). However, if I build my string manually from the command line it is displayed correctly.
It is easy to parse out the directory path and detect the '$' to denote a variable for expansion. However, I'm not sure whether I'd end up still being in the same boat. Any ideas now?