Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi Frens,
I have to search for a string and need to display a error message if that sting is not found in the file....
I can use the command:
> grep "String" filename
for searching the string but, in addition to that I have to add - if that string not found echo "Sting not found "
Can anyone help me for this?Thanks in advance...

a simple if works:
#!/usr/bin/kshisfound=$(grep word file)
if [[ $isfound = "" ]];then
echo not found
else
echo $isfound
fi

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |