csh shell script - test the grep command has been sucessfully match pattern.

I don't know how to test the variable y whether or not containing something. Please see code below.
#!/bin/csh 
set x = 123
set y = `echo $x | grep -E "[6-9]+"`
if $y has something   //my question is here... don't know how to test it
    echo Pattern found
else
    echo Pattern not found
endif

Open in new window

chiachiaAsked:
Who is Participating?
 
ozoConnect With a Mentor Commented:
if( "$y" != '' )then
   echo Pattern found
else
    echo Pattern not found
endif
0
 
chiachiaAuthor Commented:
Thank you very much!
0
All Courses

From novice to tech pro — start learning today.