Do you need grep output to connect to your command? The answer is simpler if you do not. In this case, since the grep return code is successful only if it finds a match, you can use && or if :
curl http://website.com 2> /dev/null | grep -q -i "test" && <MY-COMMAND> if curl http://website.com 2> /dev/null | grep -q -i "test"; then <MY-COMMAND> fi
The && operator is a shorthand way to do if-else checks. This is a short circuit operator, which means that the right side will only be executed if the left side fails.
If you need to transfer the output to your command, you need to save the output to a temporary file, check the correspondence and then execute the command:
if curl http://website.com 2> /dev/null | grep -i "test" > /tmp/grep.txt; then <MY-COMMAND> < /tmp/grep.txt fi
source share