Re: bash scripts: using ~<username>
- From: "Angel Tsankov" <fn42551@xxxxxxxxxxxxxxxx>
- Date: Mon, 18 Sep 2006 10:03:21 +0300
When typed at the bash prompt, ~<username> is expanded to the home
directory of the specified user. [Why can'] I use this construct in
scripts? Or, if I can, then how?
Works for me:
clairissa:~$ cat temp.sh
#!/bin/bash
cd ~guest
pwd
clairissa:~$ ./temp.sh
/home/guest
...maybe you'd better post an example of how it doesn't work for you,
with the exact command that's getting executed. Remember, when
debugging shell scripts, "set -x" can give you a whole lot of
information.
Here's how it does not work:
#~/bin/bash
echo ~$1 # prints ~<username> to stdout
.
- Follow-Ups:
- Re: bash scripts: using ~<username>
- From: Chris F.A. Johnson
- Re: bash scripts: using ~<username>
- Prev by Date: Re: Making backups of DVD's...
- Next by Date: Re: how to backspace in vi?
- Previous by thread: Re: bash scripts: using ~<username>
- Next by thread: Re: bash scripts: using ~<username>
- Index(es):
Relevant Pages
|