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.
Why doesn't wget --help | grep '-q' work? It's obviously interpreting the dash in a weird way, but I don't understand why it can't interpret it literally. Does it interpret it as stdout? Fgrep or grep -F doesn't work either.
You've got "grep" treating the -q as if it were an option for "grep" rather than a search term. You need to signal to "grep" that you have no more options and that the subsequent text should be treated as a search term. Adding a double dash -- will tell "grep" that there are no more options to follow.
Code:
wget --help | grep -- '-q'
Many programs need that double dash when working with patterns or text that start with a dash.
userx@voided1.what~>> wget --help | grep "\-q"
-q, --quiet quiet (no output)
-Q, --quota=NUMBER set retrieval quota to NUMBER
userx@voided1.what~>> wget --help | grep 'q'
-q, --quiet quiet (no output)
-nv, --no-verbose turn off verboseness, without being quiet
requests in timestamping mode
-Q, --quota=NUMBER set retrieval quota to NUMBER
--referer=URL include 'Referer: URL' header in HTTP request
--method=HTTPMethod use method "HTTPMethod" in the request
--warc-file=FILENAME save request/response data to a .warc.gz file
-p, --page-requisites get all images, etc. needed to display HTML page
Thank you all for your answers. I realised now that I actually tried to escape the dash, but I actually used a slash instead of a backslash, and that's why I thought that it doesn't work even with the escape character. But you need to quote or double quote in any case, it doesn't work simply by writing -q.
@schneidz I was thinking of stdrr too and was thinking of redirecting it to a file and the grep-ing it - but that's not so much fun.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.