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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| 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 |
| |||
| 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 |
| ||||
| 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 ** ************************************************** ****************** |