[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: invoke tilde expansion on quoted string
From: |
Chris F.A. Johnson |
Subject: |
Re: invoke tilde expansion on quoted string |
Date: |
Sat, 12 Nov 2011 02:09:40 -0500 (EST) |
User-agent: |
Alpine 2.00 (LMD 1167 2008-08-23) |
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)