Linked Questions
40 questions linked to/from How does Linux handle multiple consecutive path separators (/home////username///file)?
60
votes
3
answers
21k
views
unix, difference between path starting with '/' and '//' [duplicate]
In unix/linux, any number of consecutive forwardslashes in a path is generally equivalent to a single forwardslash. eg.
$ cd /home/shum
$ pwd
/home/shum
$ cd /home//shum
$ pwd
/home/shum
$ cd /home///...
72
votes
1
answer
65k
views
What do double slashes mean in UNIX path? Is `cd dir/subdir//` valid? [duplicate]
Possible Duplicate:
How linux handles multiple path separators (/home////username///file)
Do cd dir/subdir/ and cd dir/subdir// mean the same thing in UNIX?
Will the latter work out? Does the ...
3
votes
3
answers
6k
views
What is the difference between a directory name that ends with a slash and one that does not? [duplicate]
Is there any difference between a directory name such as
mydirectory
and
mydirectory/
I noticed this happens when I execute ls in some directories - some of the directory names have a slash and some ...
2
votes
2
answers
2k
views
difference between /dir and /dir/ [duplicate]
Consider a symlink I am making to my Music directory named music.
ln -s Music music
now consider following sequence of commands:
edward@ArchLinux:~$ readlink music
Music
edward@ArchLinux:~$ readlink ...
1
vote
2
answers
497
views
'cd //; pwd' # What's happening here? [duplicate]
A coworker just pointed out something odd, and I'm curious what the explanation might be.
On the systems I've tried, cd /', 'cd //', and 'cd ///' all have the effect of changing directory to the file ...
4
votes
1
answer
131
views
Difference between / and // [duplicate]
On the bash prompt one, three or more slashes (/,///,////, ...) are treated as a single slash, whereas two slashes (//) are left as is:
12:07 $ cd /
12:07 $ pwd
/
12:07 $ cd //
12:07 $ pwd
//
12:07 $ ...
2
votes
1
answer
156
views
Why does cd-ing to // set PWD to //, but more slashes just gives /? [duplicate]
On my ubuntu box I accidentally just did cd // and noticed that my current path changed to //. ls showed the contents of my root directory.
When I try cd /// (or any other number of slashes) I'm just ...
3
votes
0
answers
79
views
When coding for Unix/Linux is it convention to use a trailing slash on path names, or to omit it? [duplicate]
When programming for Unix/Linux, is it best practice to use a trailing slash, or to omit it?
For example:
Trailing slash
baseDir="/path/to/dir/"
#code#
outPath=${baseDir}addition/to/path/
No ...
0
votes
0
answers
75
views
What directory is // [duplicate]
$ cd /
/$ ls
bin dev home initrd.img.old lib64 media opt root sbin sys usr vmlinuz
boot etc initrd.img lib lost+found mnt proc run srv tmp var vmlinuz....
127
votes
9
answers
13k
views
On what systems is //foo/bar different from /foo/bar?
Throughout the POSIX specification, there's provision (1, 2, 3...) to allow implementations to treat a path starting with two / specially.
A POSIX application (an application written to the POSIX ...
91
votes
4
answers
70k
views
When should I use a trailing slash on a directory? [duplicate]
Possible Duplicate:
How linux handles multiple path separators (/home////username///file)
Most commands I use in linux behave exactly the same whether I include the trailing slash / character on ...
65
votes
3
answers
5k
views
Shebang starting with `//`?
I'm confused about following script (hello.go).
//usr/bin/env go run $0 $@ ; exit
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
It can execute. (on MacOS X 10.9.5)
$ ...
44
votes
4
answers
11k
views
Should I include a trailing slash / in a symlink to a directory?
Symlinking to a directory gives to different results with ls -l depending on whether I ln -s dir or ln -s dir/. But what's the actual difference, and which one should I prefer why?
26
votes
3
answers
39k
views
how to strip the last slash of the directory path?
I have a script which requires an directory as one argument.
I want to support the two form: one is like
a/b/c
(no slash at the end) and another is like
a/b/c/
(has slash at the end).
My ...
20
votes
5
answers
22k
views
Building paths robustly
Say I have several variables in a shell script (e.g. in zsh):
FOLDER_1, FOLDER_2, etc.
These variables refer to folders descending from /. For example, if I have a path /home/me/stuff/items
the ...