Coding in UNIX make, I have written:
cat $ sString | grep sSubstring > sResult
So I want to check if sString contains sSubString and, if it does, put the result in sResult.
Background: I have put the contents of a file in sString - if sSubString is present in the file, then sResult contains each line of the file containing sSubString.
This works fine when sSubString is in sString. When it is not, I get Error Code 1.
How can I handle this correctly? The complete code is:
cat $ sString | grep sSubstring > sResult
if [ -s sResult -gt 0 ];then \
(echo "substring present" ) \
else (echo "substring not present" ) ;fi
(With the error code, I never get to the else .)