is /. superfluous? why not just say / ?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers is /. superfluous? why not just say / ?
# 1  
Old 07-06-2006
is /. superfluous? why not just say / ?

is /. superfluous? why not just say / ?

I can see a use for . on its own. But /. seems superfluous/redundant.

I'm guessing it must have some good reason, there's a whole website named after it!!
# 2  
Old 07-06-2006
In many contexts /. (i.e. the current directory that is the root directory) is the same as / (the root directory) just as ./ (the directory that is the current directory) is the same as . (the current directory), e.g. they both work predictably for cd and for ls if no filename is provided.

Wikki says about slashdot the site:
Quote:
The site's slogan is "News for nerds. Stuff that matters." Officially, the name "Slashdot" was chosen to confuse those who tried to pronounce the URL of the site (h-t-t-p-colon-slash-slash-slash-dot-dot-org).
!
# 3  
Old 07-06-2006
you say in many contexts they're the same. But is there any case you can name where /. is not the same as / ? e.g. one works and the other doesn't?

note-
But regarding your use of the term 'current directory'
dot is a pointer to some directory not necessarily the current one. If you're in /home/blob/ and you do ls /. then the current directory is still /home/blob/
(pwd displays current directory, so that defines current directory) The / directory is just the one that ls is called on. I don't know of another term for the directory passed as an argument/parameter to a command. It's not (necessarily) the current/working directory. It could be any directory.
# 4  
Old 07-06-2006
Every directory is required to have an actual entry called . and another called .. and . is required to be a link to the directory that contains it. As long as everything is hunky-dory, / and /. are pretty similar. The second one takes longer since after finding / we look inside to find . and then we open that. Should the . entry be damaged, the open might fail or it might open some other file. But I don't recall ever seeing anyone open /. in that form.
# 5  
Old 07-06-2006
many thanks
# 6  
Old 07-07-2006
Quote:
Originally Posted by james hanley
you say in many contexts they're the same. But is there any case you can name where /. is not the same as / ? e.g. one works and the other doesn't?
listing /mnt shows the directory mnt in /
$ ls -ld /mnt
drwxr-xr-x 2 bin bin 512 16 Apr 2003 /mnt

listing /.mnt looks for a file called .mnt in /
$ ls -ld /.mnt
ls: 0653-341 The file /.mnt does not exist.

Interestingly
$ ls -ld /./mnt
drwxr-xr-x 2 bin bin 512 16 Apr 2003 /./mnt
and even (ad infinitum...)
$ ls -ld /./././././mnt
drwxr-xr-x 2 bin bin 512 16 Apr 2003 /./././././mnt !!

Quote:
Originally Posted by james hanley
note-
But regarding your use of the term 'current directory'
dot is a pointer to some directory not necessarily the current one. If you're in /home/blob/ and you do ls /. then the current directory is still /home/blob/
(pwd displays current directory, so that defines current directory) The / directory is just the one that ls is called on. I don't know of another term for the directory passed as an argument/parameter to a command. It's not (necessarily) the current/working directory. It could be any directory.
True - I got a bit tied up in definitions in the earlier post - it's only the current directory if it is at the start of a relative path (.*) and it's not necessarilly the current directory if it's absolute (/. or /etc/.) or if it's not at the start of the path (./../.) (although it could be!).

Tired now - can I have a lie down till my head stops hurting Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl: How to avoid warnings for superfluous values returned?

Hi all, a question for the Perl knowledgeable: I have use warnings; enabled. I use something like: ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); In the further code I only work with some of the returned variables, as the others I have no need for. Though the... (1 Reply)
Discussion started by: zaxxon
1 Replies
Login or Register to Ask a Question