Question: I need a one liner which displays 'yes' or 'no' whether grep finds any results.

I have played with `grep -c`, but without success.

Answer: 
How about:

```
uptime | grep user && echo 'yes' || echo 'no'
uptime | grep foo && echo 'yes' || echo 'no'

```

Then you can have it quiet:

```
uptime | grep --quiet user && echo 'yes' || echo 'no'
uptime | grep --quiet foo && echo 'yes' || echo 'no'

```

From the grep manual page:

> 
> EXIT STATUS
> 
> 
> Normally, the exit status is 0 if selected lines are found and 1
>  otherwise. But the exit status is
>  2 if an error occurred, unless the -q or --quiet or --silent
>  option is used and a selected line is
>  found.
> 
> 
>
This version is intermediate between **[Weboide's](https://serverfault.com/questions/153012/echo-based-on-grep-result/153013#153013)** version and **[radius's](https://serverfault.com/questions/153012/echo-based-on-grep-result/153015#153015)** version:

```
if grep --quiet foo bar; then echo "yes"; else echo "no"; fi

```

It's more readable than the former and it doesn't unnecessarily use `$?` like the latter.