Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
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.
|
|
07-19-2004, 11:57 PM
|
#1
|
LQ Newbie
Registered: Jul 2004
Posts: 27
Rep:
|
Unexpected output from 'ls' when using glob expressions
I get the following output when running the command 'ls [A-M]*' in one of my directories:
debug.test
debug.test~
Makefile
Makefile~
Makefile.example
mm.py*
mfiles:
mall
mclean
mclean~
mflags
mtests
mtests~
and just because I was interested I ran 'ls [a-m]*' in the same dir and got the following:
debug.test
debug.test~
mm.py*
mfiles:
mall
mclean
mclean~
mflags
mtests
mtests~
So, it looks like the lower-case version of the command works, but what about the upper-case version. Why am I getting all those lower-case results? I''m running Mandrake 10.0 by the way.
|
|
|
07-20-2004, 01:10 AM
|
#2
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
I've got Red Hat 8, and I see something similar. Both (lowercase and uppercase) can be demonstrated as "broken". I'll give an example in a sec. However, it's not a problem with ls, it's a problem with bash. The shell is supposed to handle wildcard expansion, and then call the command. So ls just sees the list of files that bash says match your fileglob.
Anyway, the experiment I ran was this:
Code:
$ touch Makefile
$ touch makefile
$ touch MAkefile
$ ls [A-M]*
makefile Makefile MAkefile
$ ls [a-m]*
makefile
$ ls M[a-m]*
Makefile MAkefile
So it looks like there is some inconsistent behavior, or it's something I don't quite understand. The lowercase version worked in the second example, but failed in the third. I dunno... I'm sure I'll lose some sleep over it though
|
|
|
07-20-2004, 01:40 AM
|
#3
|
Senior Member
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,305
Rep:
|
/work/work# touch Makefile
/work/work# touch makefile
/work/work# touch MAkefile
/work/work# ls
total 3
1 . 3 .. 0 MAkefile 0 Makefile 0 makefile
/work/work# ls [a-m]*
0 makefile
/work/work# ls [A-M]*
0 MAkefile 0 Makefile
works here.
bash2 --version
GNU bash, version 2.03.0(2)-release (i486-pc-linux-gnu)
Copyright 1998 Free Software Foundation, Inc.
keep in mind with the globs, that it'll list directories contents with those starting letters too.
|
|
|
07-20-2004, 03:21 AM
|
#4
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
I ran those examples in a completely clean directory; just the three bogus makefiles.
My bash version is a little different:
Code:
$ bash --version
GNU bash, version 2.05b.0(1)-release (i686-pc-linux-gnu)
Copyright (C) 2002 Free Software Foundation, Inc.
I checked the man page for bash to make sure there were no special cases for using the square brackets, and didn't see anything. Ugh... now I may be forced to download the code and look. Sometimes I wish I didn't know C...
|
|
|
07-20-2004, 04:43 AM
|
#5
|
Senior Member
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,305
Rep:
|
i just tried it with 2.05a and got the same as i did before. maybe you have some ls alias that's messing things up.
|
|
|
07-20-2004, 10:39 AM
|
#6
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
That's a good point, but I checked the output of alias, and nothing is listed for ls:
Code:
$ alias
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
And just to make absolutely sure:
Code:
$ for file in [A-M]*
> do
> echo ${file}
> done
makefile
Makefile
MAkefile
The other variations I did earlier give the same results in the for-loop format as well. I wish I was just pulling your leg, but those are the results I get. So bash is still my #1 suspect (or some other hidden/unknown setting).
|
|
|
07-20-2004, 10:35 PM
|
#7
|
LQ Newbie
Registered: Jul 2004
Posts: 27
Original Poster
Rep:
|
Thank you for the replies.
DarkHelmet, I actually have the same bash version as you do:
Code:
$ bash --version
GNU bash, version 2.05b.0(1)-release (i586-mandrake-linux-gnu)
Copyright (C) 2002 Free Software Foundation, Inc.
whansard, you said you had tried it with 2.05a but I have 2.05b, so maybe it's the shell after all.
|
|
|
07-22-2004, 03:21 AM
|
#8
|
Senior Member
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,305
Rep:
|
i just compiled 2.05b from fedora core2's source rpm. i didn't apply any of the patches. look at all this crap. i got the same results i got before.
2 . 4 bash-2.05b-rereadline.patch
4 .. 4 bash-2.05b-restrict.patch
4 bash-2.02-security.patch 4 bash-2.05b-slow.patch
4 bash-2.03-paths.patch 4 bash-2.05b-subst.patch
4 bash-2.03-profile.patch 4 bash-2.05b-utf8.patch
4 bash-2.04-compat.patch 4 bash-2.05b-warnings.patch
4 bash-2.05-ia64.patch 4 bash-2.05b-xcc.patch
8 bash-2.05a-interpreter.patch 1504 bash-2.05b.tar.bz2
4 bash-2.05a-loadables.patch 32 bash-completion-20020220.tar.gz
8 bash-2.05a-requires.patch 1436 bash-doc-2.05b.tar.bz2
4 bash-2.05a-shellfunc.patch 20 bash.spec
4 bash-2.05b-003fix.patch 4 bash205b-001
8 bash-2.05b-complete.patch 4 bash205b-002
4 bash-2.05b-debuginfo.patch 4 bash205b-003
4 bash-2.05b-display.patch 4 bash205b-004
8 bash-2.05b-locale.patch 4 bash205b-005
4 bash-2.05b-manso.patch 4 bash205b-006
4 bash-2.05b-mbinc.patch 4 bash205b-007
4 bash-2.05b-overread.patch 4 dot-bash_logout
4 bash-2.05b-pgrp_sync.patch 4 dot-bash_profile
4 bash-2.05b-readline-init.patch 4 dot-bashrc
4 bash-2.05b-readline-oom.patch
this is the only file i used from it.
1504 bash-2.05b.tar.bz2
|
|
|
All times are GMT -5. The time now is 02:25 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
|
|