Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #179449

Re: When specifying path to file - confused about ./ and ~/

From <tomas@tuxteam.de>
Newsgroups linux.debian.user
Subject Re: When specifying path to file - confused about ./ and ~/
Date 2017-03-27 14:50 +0200
Message-ID <tpCfU-87G-27@gated-at.bofh.it> (permalink)
References <tpAQN-79D-3@gated-at.bofh.it> <tpB0u-7gY-9@gated-at.bofh.it> <tpBjP-7ro-9@gated-at.bofh.it> <tpBWz-80f-53@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Mar 27, 2017 at 11:25:30PM +1100, David wrote:
> On 27 March 2017 at 22:39, Richard Owlett <rowlett@cloud85.net> wrote:
> >> On 03/27/2017 01:14 PM, Richard Owlett wrote:
> >  *Please avoid trying to briefly explain.*
> >  *_Please refer me to a good web page._

Sorry, richard: no web page, but perhaps something to start:

  ./ means "HERE"
  ~/ means "HOME"

You can move to other places with "cd" and ask where you
are currently with "pwd" or "echo $CWD", but your home
stays at "/home/richard" -- or wherever it is.

> http://www.ee.surrey.ac.uk/Teaching/Unix/unix1.html
> http://www.ee.surrey.ac.uk/Teaching/Unix/unix2.html
> 
> Sections 1.4, 1.6 part 2, and 2.1 demonstrate use of '.' and '~' to
> represent directory names.
> 
> To the best of my knowledge, '.' is intrinsic to the filesystem

Yes and no (see below)

> design, whereas expansion of '~' is handled by your shell.

Yes. The shell expands ~ to your current *home* directory (and it
expands ~foo to foo's home directory).

Now to the "yes and no": yes: every directory has two entries: ".",
which resolves to the directory itself, and "..", which resolves
to the directory's parent. This is the "intrinsic" part, i.e.
the "yes" part.

To the "no" part: in the shell, names of files are often resolved
using some default mechanism. If you invoke a command, then (unless
it's a shell builtin), the shell looks for this command as an
executable in one of the directories listed in the shell environment
variable PATH. Unless you give an explicit directory, as in
"foo/command", where the shell would look in directory foo (relative
to the current working directory, CWD [1]). Thus, ./command would
look in the current working directory.

> I hope someone else here will correct or elaborate that statement if necessary.

So yes, correct, but some further explanation might help in
understanding how to use it in a shell.

regards

[1] Of course, if you start your path with /, it's an absolute
   path, like /usr/local/bin/foo/command.

- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAljZCdMACgkQBcgs9XrR2kYn2ACcD3n8rX7DGK6ODY+XYt+ni6+N
0pAAn0IiFfFlpgrcGgAwb52n/9Uypqch
=B3UM
-----END PGP SIGNATURE-----

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

When specifying path to file - confused about ./ and ~/ Richard Owlett <rowlett@cloud85.net> - 2017-03-27 13:20 +0200
  Re: When specifying path to file - confused about ./ and ~/ Peter Ludikovsky <peter@ludikovsky.name> - 2017-03-27 13:30 +0200
    Re: When specifying path to file - confused about ./ and ~/ Richard Owlett <rowlett@cloud85.net> - 2017-03-27 13:50 +0200
      Re: When specifying path to file - confused about ./ and ~/ David <bouncingcats@gmail.com> - 2017-03-27 14:30 +0200
        Re: When specifying path to file - confused about ./ and ~/ <tomas@tuxteam.de> - 2017-03-27 14:50 +0200
          Re: When specifying path to file - confused about ./ and ~/ Richard Owlett <rowlett@cloud85.net> - 2017-03-27 16:30 +0200
            Re: When specifying path to file - confused about ./ and ~/ <tomas@tuxteam.de> - 2017-03-27 16:40 +0200
              Re: When specifying path to file - confused about ./ and ~/ Richard Owlett <rowlett@cloud85.net> - 2017-03-27 17:50 +0200
                Re: When specifying path to file - confused about ./ and ~/ <tomas@tuxteam.de> - 2017-03-27 21:40 +0200
          Chaos of confusion RESOLVED - was [Re: When specifying path to file -  confused about ./ and ~/] Richard Owlett <rowlett@cloud85.net> - 2017-04-03 14:50 +0200
        Re: When specifying path to file - confused about ./ and ~/ Richard Owlett <rowlett@cloud85.net> - 2017-03-27 16:00 +0200
      Re: When specifying path to file - confused about ./ and ~/ Brian <ad44@cityscape.co.uk> - 2017-03-27 21:30 +0200
        Re: When specifying path to file - confused about ./ and ~/ Richard Owlett <rowlett@cloud85.net> - 2017-03-27 22:00 +0200
          Re: When specifying path to file - confused about ./ and ~/ Brian <ad44@cityscape.co.uk> - 2017-03-27 23:20 +0200
          Re: When specifying path to file - confused about ./ and ~/ kAt <giathnygeia@openmailbox.org> - 2017-03-28 00:10 +0200
            Re: When specifying path to file - confused about ./ and ~/ Ben Caradoc-Davies <ben@transient.nz> - 2017-03-28 00:30 +0200
            Re: When specifying path to file - confused about ./ and ~/ Mark Fletcher <mark27q1@gmail.com> - 2017-03-28 02:00 +0200
            Re: When specifying path to file - confused about ./ and ~/ David Wright <deblis@lionunicorn.co.uk> - 2017-03-28 03:20 +0200
            Re: When specifying path to file - confused about ./ and ~/ songbird <songbird@anthive.com> - 2017-03-28 19:20 +0200
              Re: When specifying path to file - confused about ./ and ~/ Brian <ad44@cityscape.co.uk> - 2017-03-28 19:30 +0200
  Re: When specifying path to file - confused about ./ and ~/ The Wanderer <wanderer@fastmail.fm> - 2017-03-27 14:40 +0200
    Re: When specifying path to file - confused about ./ and ~/ Mark Fletcher <mark27q1@gmail.com> - 2017-03-27 15:30 +0200
      Re: When specifying path to file - confused about ./ and ~/ David Wright <deblis@lionunicorn.co.uk> - 2017-03-27 17:00 +0200
      Re: When specifying path to file - confused about ./ and ~/ Richard Owlett <rowlett@cloud85.net> - 2017-03-27 17:10 +0200
    Re: When specifying path to file - confused about ./ and ~/ Richard Owlett <rowlett@cloud85.net> - 2017-03-27 16:40 +0200
      Re: When specifying path to file - confused about ./ and ~/ Jochen Spieker <ml@well-adjusted.de> - 2017-03-27 17:10 +0200

csiph-web