Take the 2-minute tour ×
User Experience Stack Exchange is a question and answer site for user experience researchers and experts. It's 100% free, no registration required.

Directory pathnames in code can be used mostly with or without a separator character at the end. So for example, the following commands in a Unix shell are identical:

  • ls /usr/bin
  • ls /usr/bin/

Or similarly in a Windows console:

  • dir C:\Windows
  • dir C:\Windows\

Also notably, most servers don't care about a (missing) slash after a URL path:

Occasionally, I've seen this exchangeability reflected by inconsistent usage in plain text, where directory names are presented to the reader sometimes with a separator at the end and sometimes without, even in the same context.

When writing human-readable text, like a manual page or a log entry, when is it a good idea to append a directory separator after a pathname, and when not? What are advantages and disadvantages of the different representations?

share|improve this question
2  
This question doesn't appear to have anything to do with UX. –  Rich Oct 9 '13 at 2:36
    
The ls commands are not identical if bin is a symbolic link. –  CL. Oct 9 '13 at 8:21
    
@CL yes, the representations are different, only equivalent most of the times. That adds to unclarity for many unexperienced readers. –  GOTO 0 Oct 9 '13 at 8:53
add comment

2 Answers

If user reads /usr/bin/ he will immediately knows that bin is a directory and not a file. If user reads /usr/bin he has no make distinction.

How Operating Systems make this job? When using the a command like ls -l in Unix or dir in Windows, the output makes the distinction between files and directories like this

  • Unix

    -rw-r--r-- 1 root root 15276 Oct 5 2004 a2ps.cfg

    drwxr-xr-x 4 root root 4096 Feb 2 2007 acpi

where the first symbol is - for a file and d for a directory

  • Windows

    05/14/2010 02:00 AM 135 README.TXT

    04/26/2013 11:08 AM <DIR> users

where 135 is the file size in bytes (meaning it's a file), and <DIR> is the the directory tag.

share|improve this answer
add comment

Browsers generally append a trailing slash when visiting the root of a website (www.google.com).

In terms of web design/development, there is a big difference between the following URLs if you're using relative links:

  • example.com/foo
  • example.com/foo/

If there is a link to ./ within the document (eg. <a href="./">elsewhere</a>), the page that you'll end up on is quite different:

  • example.com/foo -> example.com/
  • example.com/foo/ -> example.com/foo/
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.