On 2014-12-29 14:01, Gil Dawson wrote:
I'm having a little problem understanding the Unix terminology.

You may find Chapter 2 of the freely available book "The Linux Command Line" ( http://linuxcommand.org/tlcl.php ) to be helpful. Although this book is about Linux, not MacOS X, both are based on Unix.

This paragraph has me stumped.

    '...if the filenames ... begin with "/"'

        --I cannot imagine how a filename could begin with "/".

        Does the author possibly mean /pathname/?

        A pathname might begin with either a "/" or a "~", would it not?


Configuration and log files are files, whereas pathnames can point to anything. So although it may be confusing, I think that "filename" is the correct terminology here. The filename may be just the name of a file without any directory component, or it may include a relative directory component or an absolute directory component. Examples:

Simple filename: extra-stuff.conf (look for the file "extra-stuff.conf" inside the current directory)

With relative directory: my-stuff/extra-stuff.conf (look for the file "extra-stuff.conf" inside the directory "my-stuff" which in turn is in the current directory"). Note that this is the same as ./my-stuff/extra-stuff.conf

Another example with a relative directory: ../../another-place/extra-stuff.conf (go up two directory levels from the current directory, then into the directory "another-place" and then the file is extra-stuff.conf).

Absolute directory component:  /private/etc/apache2/extra-stuff.conf


    "If the filenames do *not* begin with "/", ...
    "/private/var/log/apache2/foo_log"

        --This is an example of a filename that does not begin with
        "/", right?
        I don't get it.  I see "/" at the beginning of everything.
        What would be an example of a filename that /does/ begin with "/"?


/private/var/log/apache2/foo_log" *does* begin with "/". You're trying to make too much of a distinction between pathnames and filenames.

    "/usr//private/..."

        -- What is the meaning of "//" in this context?


It has no meaning, extra slashes between directory components are ignored. This lets scripts and other programs construct filenames without having to detect and remove extraneous slashes; if a script always adds a slash, it will be there when needed and won't cause problems if it is not needed. The following are all equivalent:

/usr/private
/usr//private
/usr/private/
/////usr/////private/////

For more reading, see http://teaching.idallen.com/cst8207/12f/notes/160_pathnames.html

--
  Mark Montague
  m...@catseye.org

Reply via email to