Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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.
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.
In 1st eg: Am trying to filter the files starting with small letters in first position and numeric in 2nd position. But it also retrieves capital letters. I dunno why.
In 2eg: Am trying to filter the files starting with capital letters in first position and numeric in 2nd position. But it also retrieves small letters in 1st position. I dunno why.
Let me know, if anyone knows the root cause of this.
[root@localhost ~]# ls -ltr [a-z][0-9]*
----rwxrwx 1 root root 10 Oct 29 23:03 a2.link
-rwxr--r-- 1 root root 19 Oct 29 23:04 a3.op
-rw-r--r-- 1 root root 31478 Oct 30 03:08 a20
-rw-r--r-- 1 root root 0 Nov 1 19:45 b123
-rw-r--r-- 1 root root 0 Nov 1 19:55 a2Bcat
-rw-r--r-- 1 root root 0 Nov 1 19:55 A2bcat
-rw-r--r-- 1 root root 0 Nov 1 20:06 a1
-rw-r--r-- 1 root root 0 Nov 1 20:32 a123
-rw-r--r-- 1 root root 0 Nov 1 20:32 a12
-rw-r--r-- 1 root root 0 Nov 1 20:32 a12as
-rw-r--r-- 1 root root 0 Nov 1 20:32 a12as!
-rw-r--r-- 1 root root 0 Nov 1 20:32 a122222
[root@localhost ~]# ls -ltr [A-Z][0-9]*
-rw-r--r-- 1 root root 0 Nov 1 19:45 b123
-rw-r--r-- 1 root root 0 Nov 1 19:55 A2bcat
[root@localhost ~]#
allend - I must admit this caught me out as my computer also is returning odd info, but I did the following and still get erroneous data back?
Code:
$ LC_ALL=C ls [a-z]*
A2bcat b123
So I too am looking forward to see why this suddenly does not work
chrism01 - I read through both pages supplied and one would think the above should behave differently??
On a little further testing, it would seem I have an ignore case set somewhere, however, I have also used my unaliased ls and get the same messed up results:
Code:
$ LC_ALL=C /bin/ls a*
A2bcat
Last edited by grail; 11-02-2015 at 08:54 AM.
Reason: Extra testing
This one seemed to have fallen off the radar, but I am still in need of a solution myself as it is now affecting scripts and the like when using some of these conjunctions
I have an older machine in vm running bash 4.3.30 and it does not seem to have this issue. Do we think it might be a bash issue??
Well, it is quite an interesting one... iirc David_The_H (?) used to be a bit of a whiz at this stuff, but I haven't seen a post from him in a long time.
Whilst I'd love to see a definitive explanation, if you're using this for real (grail), then like I said above, I'd pipe it through eg grep and use real regexes.
Well if for real you mean on a regular basis, yes, as part of using my system I often use ls and with globbing. To then have to change to also include grep would seem overkill on such a simple task
Guess I will have to keep searching. It does surprise me that more people have not come across this issue (assuming it is a bash thing and not some sill setting I have somewhere)
I have a vm of my own design which does not have the issue and has latest bash. It would seem my distro provider (Manjaro) took it upon themselves to add the following to .bashrc:
Code:
shopt -s nocaseglob
Turning this off has resolved the most recent example:
Code:
$ ls
ruby/ tmp/ d2.awk* d2.rb* d2.sh* d.awk* dd_mem_test.sh* d.html d.pl* d.py* d.rb* d.sh* f1 f2 f3 f4 lxapp-fix-gtk3.sh* mount_iso.sh* pwd_gen.awk* system_info.sh* vimrc.txt
$ ls [D]*
ls: cannot access [D]*: No such file or directory
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.