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.
Through other posts, I think I'll finally be able to knock out a problem I'm having if someone can help me tweak a find statement, as I only know how to do very simple ones.
right now i'm doing a
find . -type d -iname "z*"
to find all folders who's name starts with z or Z.
Is there a way I could with one command find all folders who's name starts with the letters M through Z, without having to do the same command over and over and just changing the letter each time?
I'll have to read up on it when I get some time. good to know that such a thing exists, luckily there aren't that many letter in the alphabet so I'll do this one by hand for now.
You might like to fiddle with the above a bit, altering the regex. I don't know why it returns the "/" (root folder) but otherwise it *seems* to work. And, change the 'x' to a 'z' to suit your requirements.
Wow, is it really that straightforward? I'd see [] before but never understood what it meant, but i think i do now! its for ranges it appears. Also, what does the \ do after the [m-z] ?
It escapes the *
Otherwise the shell would interpret it, and you may end up with
fewer hits than you were after, or an error message, depending
on how many directories in the current working directory match
[m-z]*.
Thanks for providing the examples, it makes sense now, and even shows why I need to do [m-z] rather than [mz]. I'd rather learn with guidance than just get an answer than no feedback as to why that solves my problem, you would never learn that way. Appreciate the time Tinkster!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.