Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
09-11-2014, 04:55 AM
|
#1
|
Senior Member
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: SlackWare > Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy .. bullseye bookworm
Posts: 1,849
Rep: 
|
Why "ls /usr//bin/" works?
Hya
I am absolutely confused.
Code:
>ls /usr/bin
(many files.)
...
>ls /usr/bin/ > 1
>ls /usr//bin/ > 2
>ls /usr///bin/ > 3
>diff 2 3
>diff 1 2
>
"ls /usr/bin" works as I expect, so does "ls /usr/bin/"
I thought I would get an error with "ls /usr//bin/" or ...
(Debian jessie, on X86_64)
Last edited by kaz2100; 09-11-2014 at 04:57 AM.
Reason: typo
|
|
|
09-11-2014, 05:45 AM
|
#2
|
LQ Guru
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465
Rep: 
|
I'm not sure what your question is. As long as "bin" is a folder those commands will return the contents of the "/usr/bin". If you try the same thing with a file, then you will get an error. For example:
Code:
~$ ls /usr/bin/identify/
ls: cannot access /usr/bin/identify/: Not a directory
But I'm not sure if this is what you are asking.
jdk
|
|
|
09-11-2014, 05:53 AM
|
#3
|
Senior Member
Registered: Feb 2009
Posts: 1,727
|
// in a path do not matter
all commands ignore them
this is useful, for example when you join strings to a path, you do not need to care about //s
|
|
|
09-11-2014, 03:30 PM
|
#4
|
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,953
|
I'll file this under the Learn something new everyday category.
Yes, it works. Didn't know that it would simply ignore repeated slashes.
My continual lack of expertise with regular expressions is likely my blind spot here, but maybe it's more me missing an integral understanding of how the shell interprets things. I'm sure many are more well versed with the use of back-slash.
|
|
|
09-11-2014, 03:45 PM
|
#5
|
Moderator
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,349
|
It is actually from the underlying filesystem/API specifications (nothing to do with regular expressions).
I have read it somewhere in my Stevens, and as I recall it is included in POSIX. A quick search found this one from IEEE Std 1003.1, 2004 Edition (POSIX):
Quote:
3.266 Pathname
A character string that is used to identify a file. In the context of IEEE Std 1003.1-2001, a pathname consists of, at most, {PATH_MAX} bytes, including the terminating null byte. It has an optional beginning slash, followed by zero or more filenames separated by slashes. A pathname may optionally contain one or more trailing slashes. Multiple successive slashes are considered to be the same as one slash.
|
But the origin of the idea is hidden in the mists of Unix time and space, or before (myth has it that time itself did in fact exists prior to universal recognition of the Unix Epoch).
Last edited by astrogeek; 09-11-2014 at 04:06 PM.
Reason: tpos, typs, typos - and improved choice of words...
|
|
2 members found this post helpful.
|
09-11-2014, 10:00 PM
|
#6
|
Senior Member
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: SlackWare > Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy .. bullseye bookworm
Posts: 1,849
Original Poster
Rep: 
|
Hya,
Thanks for replies.
1. It looks like that
http://www.linuxquestions.org//quest...hp?p=5236421//
and
http://www.linuxquestions.org/questi....php?p=5236421
also are parsed in a same way.
2. My confusion grows, as I read the POSIX site. I do not think I understand pathname and filename correct.
cheers
P.S. What does "somewhere in my Stevens" mean? I am not a native speaker.
Last edited by kaz2100; 09-11-2014 at 10:00 PM.
Reason: typo
|
|
|
09-11-2014, 10:12 PM
|
#7
|
Moderator
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,349
|
Quote:
Originally Posted by kaz2100
P.S. What does "somewhere in my Stevens" mean? I am not a native speaker.
|
Sorry, that was a reference to (in my opinion) the most valuable Unix reference book after anything written by Ritchie, Thompson, Kernighan and company.
Advanced Programming In The Unix Environment by W. Richard Stevens
From that link:
Quote:
OSNews describes it as "one of the best tech books ever published" in a review of the second edition.
|
I have a first edition and a second edition with Rago, but the first is still my favorite (no Linux coverage, but more accessible) - get one if you can!
Last edited by astrogeek; 09-11-2014 at 10:18 PM.
Reason: tpos, typs, typos... and an extra comment
|
|
|
All times are GMT -5. The time now is 05:10 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|