Stupid bash scripting question

Bill Sconce sconce at in-spec-inc.com
Wed Aug 24 10:07:18 EDT 2005


On Wed, 24 Aug 2005 09:43:46 -0400
Cole Tuininga <colet at code-energy.com> wrote:

> 
> Ok - I'm sure the answer to this is simple, but I can't seem to figure
> the darned thing out.  In my defense, it's extremely rare that I do any
> shell scripting.  8)

It IS grungier than Python, eh?


 
> Basically, the deal is that I have a variable that contains a string
> such as "~username".  I'd like to actually expand that to the user's
> home directory.
> 
> In other words, if I have something like:
> 
> user="username"
> f="~${user}"
> 
> I'd like $f to end up with the path to username's actual home.  As it
> is, it just has the value "~username".  What magic do I need to do on my
> f assignment line?!


One way:

f=`eval "echo ~${user}"`


There's a lot going on here if you needed to discuss it, and I'll even
hope that there's a less-grungy way to do it...

HTH,
Bill



More information about the gnhlug-discuss mailing list