Stupid bash scripting question

Andrew W. Gaunt quantum at lucent.com
Wed Aug 24 10:15:01 EDT 2005


Somthing like this perhaps?

$ user="quantum"                      
$ f=`getent passwd $user|cut -f6 -d:`
$ echo $f                             
/home/quantum


Cole Tuininga 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)
>
>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?!
>
>





More information about the gnhlug-discuss mailing list