Unix Technical Forum

Slack 10 - odd behavior of ls

This is a discussion on Slack 10 - odd behavior of ls within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> i just installed slack 10 and was checking out the rc files using ls. i did cd /etc ls ...


Go Back   Unix Technical Forum > Unix Operating Systems > Slackware Linux Support

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-19-2008, 01:11 PM
Beau Tox
 
Posts: n/a
Default Slack 10 - odd behavior of ls

i just installed slack 10 and was checking out the rc files using ls.

i did

cd /etc

ls rc*

- this showed a whole bunch of rc files.. but did not indicate that they
were under a subdirectory rc.d.... in fact did not indicate rc.d existed

ls r*

- this worked as expected .. rc.d: with files in rc.d as expected

ls rc.d

- this showed rc files.. but again did not indicate rc.d exists.

Does anybody have the same problem or is it just me?

Or is this normal behavior?

thx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-19-2008, 01:12 PM
Jakub Jankowski
 
Posts: n/a
Default Re: Slack 10 - odd behavior of ls

On Sun, 04 Jul 2004 11:58:19 +0000, Beau Tox wrote:

> i just installed slack 10 and was checking out the rc files using ls.
> i did
>
> cd /etc
> ls rc*
> - this showed a whole bunch of rc files.. but did not indicate that they
> were under a subdirectory rc.d.... in fact did not indicate rc.d existed


Because your shell expands "rc*" to a list of all files/dirs beginning
with "rc". As there's only "rc.d" matching this pattern, you end up like
you'd do "ls rc.d", which is supposed to list the contents of rc.d
directory.

> ls r*
> - this worked as expected .. rc.d: with files in rc.d as expected


Because there are more files in /etc/ beginning with "r", so you end up
with something like: ls random-seed resolv.conf rmt rpc rc.d

> ls rc.d
> - this showed rc files.. but again did not indicate rc.d exists.


That's how ls(1) works.

> Does anybody have the same problem or is it just me?


Everybody, I guess.

> Or is this normal behavior?


Yes it is. Please read the manual pages for ls(1).

--
Jakub Jankowski
shasta AT spam DOT atn DOT pl

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-19-2008, 01:12 PM
Wild Wizard
 
Posts: n/a
Default Re: Slack 10 - odd behavior of ls

Beau Tox wrote:

> i just installed slack 10 and was checking out the rc files using ls.
>
> i did
>
> cd /etc
>
> ls rc*
>
> - this showed a whole bunch of rc files.. but did not indicate that they
> were under a subdirectory rc.d.... in fact did not indicate rc.d existed
>
> ls r*
>
> - this worked as expected .. rc.d: with files in rc.d as expected
>
> ls rc.d
>
> - this showed rc files.. but again did not indicate rc.d exists.
>
> Does anybody have the same problem or is it just me?
>
> Or is this normal behavior?


It is actually your shell

ls will not and can not expand the * or ? wildcards this is done by the
shell which then passes on the results to ls

You can get the same output by expanding the * yourself like so :-
ls random-seed resolv.conf rndc.key rsyncd.conf rc.d rmt rpc

if you don't want the shell to expand wildcards (they are legitimate
charactors in a filename) you then need to enclose them in quotes ''

ls 'rc*' will result in file not found however you can create that file

--
"It's kind of fun to do the impossible."
-- Walt Disney

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-19-2008, 01:20 PM
Eef Hartman
 
Posts: n/a
Default Re: Slack 10 - odd behavior of ls

Beau Tox <beautox@darkstar.example.net> wrote:
> Or is this normal behavior?


This is normal behaviour, if you ONLY give a single directory
(which rc.* will evaluate TO) the contents OF that directory
are listed. The r* will resolve to "more then one file", so then
it has to list both the files AND the contents of any directories
among those files.

Note that ls itself will never see the wildcard (rc.*) as that has
already been expanded by the shell, so it "thinks" you're only
giving it a single filespec, which happens to be a directory.
--
************************************************** ******************
** Eef Hartman, Delft University of Technology, dept. EWI/TW **
** e-mail: E.J.M.Hartman@math.tudelft.nl, fax: +31-15-278 7295 **
** snail-mail: P.O. Box 5031, 2600 GA Delft, The Netherlands **
************************************************** ******************
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:19 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com