BASH: How to NOT echo to screen with "if echo $x | grep ".*"; then"
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
BASH: How to NOT echo to screen with "if echo $x | grep ".*"; then"
if echo $x | grep ".*"; then
...
fi
Is there a way of getting around this type of stuff without actually printing it out to the screen? The user shouldn't be seeing this. I'm trying to test if the string matches the grep regex.
Note that there's a bash built-in to do this. From "man bash":
Quote:
[[ expression ]]
[...]
An additional binary operator, =~, is available, with the same precedence as == and !=. When it is used, the string to the right of the operator is considered an extended regular expression and matched accordingly (as in regex(3)).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.