Re: bash scripts: using ~<username>



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

.



Relevant Pages

  • Re: bash scripts: using ~
    ... clairissa:~$ cat temp.sh ... debugging shell scripts, "set -x" can give you a whole lot of ...
    (comp.os.linux.misc)
  • Re: Program incompatibility
    ... Interestingly, when using another emulator, Guest PC, Setup Factory ... >application of VPC 7, if it worked! ... You could try enabling the scripts and ...
    (microsoft.public.mac.virtualpc)
  • Re: bash scripts: using ~
    ... directory of the specified user. ... clairissa:~$ cat temp.sh ... debugging shell scripts, "set -x" can give you a whole lot of ...
    (comp.os.linux.misc)
  • Re: how to begin with qemu and networking
    ... When I played around with QEMU in the past I found these scripts on the ... guest to the internet it serves my need. ... guests talking to each other either on the same host or on different ...
    (Debian-User)
  • Re: bash scripts: using ~
    ... clairissa:~$ cat temp.sh ... debugging shell scripts, "set -x" can give you a whole lot of ... Either it's a hit-and-run poster or, judging by the headers, it's a troll. ... I hope I don't let the guillotine fly prematurely, but these headers remind ...
    (comp.os.linux.misc)