How to grep from multiple files given one of those files dont exist

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Elizabeth H
    New Member
    • Jan 2011
    • 19

    How to grep from multiple files given one of those files dont exist

    I am trying to grep for a particular word from two files like below. I need to find the word in one of the two files

    grep "myWord" file1 file2 && echo 1 or echo 0

    The issue is that I have to search in both the files, but sometimes one of these files doesnt exist. So even when the word is present in one of the files it stil returns a 0.
Working...