On Fri, 11 Nov 2011, Peng Yu wrote:
I know from the document that tilde expansion only works if the string
is unquoted (see below)
~$ cd '~/..'
-bash: cd: ~/..: No such file or directory
~$ cd ~/..
/Users$
I'm wondering if I already have a string variable, is there a bash
native to do tilde expansion on it.
var='~/..'
cd $var#how to change this line?
eval "cd $var"
--
Chris F.A. Johnson, <http://cfajohnson.com/>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)