LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 09-11-2014, 04:55 AM   #1
kaz2100
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,834

Rep: Reputation: 108Reputation: 108
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
 
Old 09-11-2014, 05:45 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
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
 
Old 09-11-2014, 05:53 AM   #3
a4z
Senior Member
 
Registered: Feb 2009
Posts: 1,727

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
// 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
 
Old 09-11-2014, 03:30 PM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,885
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
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.
 
Old 09-11-2014, 03:45 PM   #5
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,278
Blog Entries: 24

Rep: Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225
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.
Old 09-11-2014, 10:00 PM   #6
kaz2100
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,834

Original Poster
Rep: Reputation: 108Reputation: 108
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
 
Old 09-11-2014, 10:12 PM   #7
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,278
Blog Entries: 24

Rep: Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225Reputation: 4225
Quote:
Originally Posted by kaz2100 View Post

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
 
  


Reply

Tags
directory, error, linux, slash


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Just Curious: why do "/usr/bin/test" and "/usr/bin/[" have different sizes? DaneM Programming 5 01-06-2014 03:33 AM
[SOLVED] Cannot 'find "[" -maxdepth 1 -wholename "/usr/bin/[" ! \( -perm /g+w,o+w \)' standard_output Linux - General 5 09-13-2013 04:23 PM
script using "/usr/bin/cat error" produces "cannot open" in cron Dcrusoe Programming 6 07-22-2009 03:30 PM
problem "make"ing gtk+ "/usr/bin/env: perl -w" caid Linux - Newbie 8 07-29-2005 04:51 AM
what is "S" instead of "X" in the file permission when i look at /usr/bin/chsh? Linux_interest Linux - Newbie 4 08-28-2004 09:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration