Results 1 to 8 of 8

Thread: tilde filename question

  1. #1
    Join Date
    Jun 2008
    Location
    southeast Alaska
    Beans
    353
    Distro
    Ubuntu 12.04 Precise Pangolin

    tilde filename question

    I saw this command in a post about configuring emacs:

    Code:
    xrdb -merge ~/.Xdefaults
    I have read the tilde is a shortcut to the home directory. Is this the same as writing

    Code:
    xrdb -merge /home/myusername/.Xdefaults
    Does the tilde ever have a different meaning at the beginning of a path? (I know it refers to backup files when it's at the end of a path/filename.)

  2. #2
    Join Date
    Aug 2007
    Location
    Paris
    Beans
    5,538
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: tilde filename question

    I'm pretty sure it's always just a shortcut for /home/username. It makes it convenient for giving instructions or writing bash scripts without knowing a user's account name.

  3. #3
    Join Date
    Jun 2006
    Location
    Switzerland
    Beans
    Hidden!
    Distro
    Kubuntu Jaunty Jackalope (testing)

    Re: tilde filename question

    the ~ means the homefolder of the current user... if you're logged in as root it will be /root instead of /home/user

  4. #4
    Join Date
    Sep 2005
    Beans
    166
    Distro
    Xubuntu 8.04 Hardy Heron

    Re: tilde filename question

    Quote Originally Posted by japhyr View Post
    I saw this command in a post about configuring emacs:

    Code:
    xrdb -merge ~/.Xdefaults
    I have read the tilde is a shortcut to the home directory. Is this the same as writing

    Code:
    xrdb -merge /home/myusername/.Xdefaults
    Does the tilde ever have a different meaning at the beginning of a path? (I know it refers to backup files when it's at the end of a path/filename.)
    I believe it is the same.

    My terminal (not sure if its the terminal or ubuntu itself) will convert ~/ to /home/andy/ as soon as I type it.
    Don't eat yellow snow

  5. #5
    Join Date
    Jun 2008
    Location
    southeast Alaska
    Beans
    353
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: tilde filename question

    Thanks everyone, especially the part about writing general scripts that apply to anyone's username.

  6. #6
    Join Date
    Jan 2007
    Location
    $here ? $here : $there
    Beans
    3,717
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: tilde filename question

    You should also be aware that ~ is resolved by the shell to $HOME. So ~ isn't always valid for a path name. One common example of this is if you create a custom panel launcher, ~ will not resolve properly and you need to use the full path.
    Don't try to make something "fast" until you are able to quantify "slow".

  7. #7
    Join Date
    Jun 2008
    Location
    southeast Alaska
    Beans
    353
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: tilde filename question

    Actually, that was a question I had around this. What is $HOME? What is the difference between /home/username/directory, ~/username/directory, and $HOME/username/directory?

  8. #8
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,239
    Distro
    Kubuntu

    Re: tilde filename question

    Actually, I think you meant $HOME/directory.

    $HOME = /home/username

    $HOME is an environment variable that is initialized when you log in. To see all environment variables, open a terminal and run this command:
    Code:
    $ env

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •