I'm trying to return a boolean if a curl response has a status of 200.
curl https://www.example.com -I | grep ' 200 ' ? echo '1' : echo '0';
This however brings back:
grep: ?: No such file or directory
grep: echo: No such file or directory
grep: 1: No such file or directory
grep: :: No such file or directory
grep: echo: No such file or directory
grep: 0: No such file or directory
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
So I'm thinking (and from reading other threads) that grep doesn't support the ternary operator?
Is there a simple one liner to do this without creating a shell script? (also my grep ' 200 ' is loose but I figure I can make that more specific later)