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.
Hello
I got a problem using wildcards , I always get unexpected results , for example I wanna list the files that only start with capital letters in /etc
$ls [A-Z]*
I got strange output that contains files not have any capital letters like :
Well that is not the correct way to do it and that is the reason you are not getting expected result.
If you want to list down all the files under /etc that start with a capital letter then you should run the command as follows:
Code:
ls -a /etc | grep ^[A-Z]
You can change the path I mean instead of using ls -a /etc you can also use /var to find out the files starting with capital letters under /var directory.
Well that is not the correct way to do it and that is the reason you are not getting expected result.
If you want to list down all the files under /etc that start with a capital letter then you should run the command as follows:
Code:
ls -a /etc | grep ^[A-Z]
You can change the path I mean instead of using ls -a /etc you can also use /var to find out the files starting with capital letters under /var directory.
Thnx 4 ur help , but I really wanna use wildcard nor regexp , or you can say I wanna know what makes it give that strange output
That is because you are not running the command mentioned as root user. Try it with the root user and I am pretty sure it will work. I got the same output as you are getting when I used a regular user account.
That is because you are not running the command mentioned as root user. Try it with the root user and I am pretty sure it will work. I got the same output as you are getting when I used a regular user account.
The same result
Really I don't wanna know another method , I just wanna know why this happens , so please help me
Appears to me as some limitation with regular user account to use wildcards. When I use the regular user account I get the same output. If I use root user account I got the correct output. If I add the regular use to sudo still I get the same output.
So it appears to be some limitation with regular user account to use wildcards.
I tried all of that but still the same problem , and by the way I tried it yesterday on a Centos machine and also I had a problem like that , that's why I decided that I must figure out what's happening , I don't know if It's a bug or what !!
Hello again
I really don't want any suggestion for that function , I am just very curious to know what causes that strange output that is totally different from all what we learnt and what books say, so please help me know where the problem is
Hello Chris
The dot is not a wildcard character , I still getting unexpected results, really I need to know what causes that , I am not asking about any complex issue , It's just the basics that we learnt years ago from books, I don't know why it's not working correctly !! Please help me figuring out that.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.