It is currently Tue, 17 May 2022 03:22:47 GMT

Author Message
 tilde + variable expansion in bash

I'm having an awful time getting something to work in bash. I want to
find the
home directory of a user ... no big deal?

Simply using ~ doesn't work since the user is not running the shell. And
since I
don't know the name of the user, I can't do something like ~bob/...

However, the name of the user is set in a shell var. So, I thought that:


would work. It doesn't.

If I were to use


bash looks in the password file and finds the home directory for user
bob. However,
when using ~$USER it doesn't work. $FILE ends us as ~bob/filetoread, and
the tilde
subsitution is not done a 2nd a file by the name
~bob/filetoread is looked for,
not /home/bob/filetoread.

I think that it is just a matter of bash doing what it says it does in
the manual. First tilde expansion is done, and since what follows the
tilde isn't a username, it is left as is. Later the variable is
substituded, but that doesn't help then.

So, is there a way around this????

  /  )      /         Bob van der Poel
 /--<  ____/__
/___/_(_) /_)         http://www.**-**.com/ ~bvdpoel

 Sun, 01 Oct 2000 03:00:00 GMT   
 tilde + variable expansion in bash

Bob van der Poel <> writes:

[...tail of woe...]

eval FILE=~$(id -un)/filetoread

 Mon, 02 Oct 2000 03:00:00 GMT   
   [ 2 post ] 

Similar Threads

1. tilde expansion with variable in bash script

2. HELP:bash: making tilde expansion after command expansion...

3. Problem with tilde expansion in newer bash shells

4. Configuring tilde expansion in bash

5. variable expansion on the bash command line

6. Multiple variable expansion in bash. (ie: ${$1})

7. tcsh tilde (~) expansion problems hanging (slowing) the shell

8. tcsh tilde (~) expansion problems hanging (slowing) the shell

9. tilde expansion for filename

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software