Linux - GeneralThis 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.
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.
I went back through every command I ran in the session where it was screwed up. I can't see anything that would have any bearing on how grep, echo, or bash in general operates.
in such cases you should almost never think grep is broken (or sed or whatever). If grep was broken so clearly it would be fixed already. No, that is not a bug in the software, but misunderstanding of the environment. Believe me, grep (sed/awk/...) works exactly as planned and implemented. So you need to find out what can cause this behavior.
An easy trick to execute echo grep [0-9] (or simply echo [0-9]) and you will see it is evaluated. To keep it as is you need to avoid evaluation, you need to look for quotations (as it was already mentioned).
_____________________________________
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
Happy with solution ... mark as SOLVED
(located in the "thread tools")
in such cases you should almost never think grep is broken
I know - dumb thought. It was just so weird.
Quote:
I don't understand why you can't test what you've learned---take your original example and repeat using quotes.
I can't test the solution if I can't reproduce the problem. Trying the solution in an environment that isn't messed up doesn't yield any useful results:
The results will depend on whether any files with names that are just a single digit exist in the current directory. Try your "echo" test when there is a file named "3" (without the quotes) in the current directory. Try it again when there are files named "3", "4", and "5", and consider what grep would do in that case.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.