Questions tagged [slash]

38 questions
149
votes
6 answers

How does Linux handle multiple consecutive path separators (/home////username///file)?

I'm working on a python script that passes file locations to an scp subprocess. That's all fine, but I'm in a situation where I may end up concatenating a path with a filename such that there's a double '/ in the path. I know that bash doesn't care…
Falmarri
  • 12,897
  • 17
  • 58
  • 71
124
votes
9 answers

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 specification to be portable to all POSIX compliant…
Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501
82
votes
4 answers

When should I use a trailing slash on a directory?

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 the end of a directory name or not. For example: ls…
Cory Klein
  • 18,391
  • 26
  • 81
  • 93
67
votes
1 answer

What do double slashes mean in UNIX path? Is `cd dir/subdir//` valid?

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 difference have any special meaning for cd, mv, ls, or…
San
  • 887
  • 2
  • 11
  • 13
64
votes
3 answers

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) $ chmod +x hello.go $ ./hello.go hello, world I…
kawty
  • 743
  • 5
  • 7
60
votes
3 answers

unix, difference between path starting with '/' and '//'

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///shum $ pwd /home/shum Yet for some reason two…
Shum
  • 1,335
  • 4
  • 14
  • 19
26
votes
3 answers

How to delete a file named "filen/ame" (with slash) on an ext4 filesystem in debugfs?

Playing with e2fsprogs debugfs, by change/accident, a file named filen/ame was created. Obviously the forward slash character / serves as the special separator character in pathnames. Still using debugfs I wanted to remove the file named filen/ame,…
humanityANDpeace
  • 13,722
  • 13
  • 61
  • 107
23
votes
3 answers

Kernighan and Pike challenge: how to put a slash in a filename?

I've just encounter the following question in Unix Programming Environment, the Kernighan and Pike's classic book on Unix (I found the below text on p. 79 of year 1984 edition, ISBN:0-13-937699-2): Exercise 3-6. (Trick question) How do you get a /…
firegurafiku
  • 463
  • 1
  • 4
  • 8
17
votes
3 answers

the slash (/) after a directory name on shell commands

I have a little question here. If I have two files, say filea and fileb, mv filea fileb would delete fileb rename filea to fileb Then if I have two directories, say dira and dirb, mv dira dirb would move dira into dirb (it will become…
phunehehe
  • 20,030
  • 27
  • 99
  • 151
11
votes
4 answers

Where can I find a definitive answer for what `*/` means in Bash or Zsh?

I was trying to look into some reference from O'Reilly about Unix and Bash about the meaning of */ but couldn't find any. We can echo */ and see all the directories. It seems like it means all "directories" only, while * means "all files and…
nonopolarity
  • 2,969
  • 6
  • 31
  • 41
6
votes
1 answer

Escape a mm/dd/YY backup date in a file name

I have been trying to: cp file.csv file.$(date +%D).csv But it fails because the filenames is: file.03/27/19.csv with the slash of separate directories. And I have been trying again to: cp file.csv file.$(printf "%q" $(date +%D)).csv But it still…
tres.14159
  • 234
  • 1
  • 2
  • 6
6
votes
3 answers

What does dot forward slash forward slash mean (.//)?

I was querrying a server using a command like this: find ./ -type f -name 'filename" I got many files starting with .//library or .//user What do these things mean?
munchschair
  • 257
  • 3
  • 9
5
votes
2 answers

What causes ln: //: Is a directory?

When linking a directory to root, I get this error: $ ln -s ~/inbox/ / $ ln: //: Is a directory Bash autocompletes the directory path by adding a /. I've tried escaping without success. $ ln -s ~/inbox / works though. Why is this?
Igorio
  • 7,279
  • 7
  • 20
  • 11
5
votes
2 answers

Is it ok that find displays double forward-slash?

Is it a bug that, when I find ./path/here/ I get: ./path/here//foo ./path/here//bar I know find wants me to specify the path without the trailing slash, but surely it can detect the path that tab-completing leaves me with and adjust its output…
Bobby Jack
  • 350
  • 3
  • 11
4
votes
1 answer

Test for link with trailing slash?

I created in /tmp/test/ mkdir somedir ln -s somedir/ somelink I want to loop through only directories: for file in */ ; do if [[ -d "$file" && ! -L "$file" ]]; then echo "$file is a directory"; fi; done but why does this show somelink is…
rubo77
  • 27,777
  • 43
  • 130
  • 199
1
2 3