if statement in bash

Alway had problems with If statements

This will tell me if I have a default route
netstat -r | grep default

Now if I want to say "yeh" if i have a default route, can someone fix this

if [[     netstat -r | grep default    ]] then echo "yeh"  fi
TIMFOX123Asked:
Who is Participating?
 
woolmilkporcConnect With a Mentor Commented:
if netstat -r | grep -q default ; then echo yeh; fi
0
 
pony10usConnect With a Mentor Commented:
if [ netstat -r | grep default ]; then
               echo yeh
            fi
0
 
woolmilkporcConnect With a Mentor Commented:
grep -q

to get rid of grep's output.
0
 
arnoldCommented:
netstat -n | grep default 2>&1 >/dev/null && echo yeh
0
 
TIMFOX123Author Commented:
thanks porky
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.