-
The following code block is C shell and is working. Can some body "translate" it to Korn shell? Thank you!
if { ( cat ck_Alert.log|grep "Mi" >& /dev/null ) } then
echo "Find the pattern"
endif
-
dummy=`grep -q "Mi" ck_Alert.log`
if [ $? -eq 0 ] ; then
echo "Find the pattern"
fi
-amar
-
amar,
You are so kind to provide this solution. However, I need to do the similar tests 10 times in my major script. I prefer to test the exit status in the "if condition" instead of testing seperately. I can do this on C shell. I just wonder if Korn shell can do the same thing. (I mean, do the cat-grep-test exit status in the same line.)
Thank you!
-
if [[ -n `cat ck_Alert.log|grep "Mi"` ]]
then
echo "Found the pattern"
fi
Sam
Thanx
Sam
Life is a journey, not a destination!
-
or, if you want to stick to "grep"..........
if [ `grep "Mi" ck_Alert.log | wc -l` -ne 0 ] ; then
echo found
fi
-amar
-
Thank you!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|