You can do the search with one grep command as follows:
Code:
grep -i "\b12\b.*nov.*2007" myfile
Remember that grep searches for
patterns. Patterns can be described as 'regular expressions'. So that weird string "\b12\b.*nov.*2007" tells grep to search for the following:
'\b12\b" search for '12' that is by itself.
".*" followed by any no. of any characters.
"nov" followed by the string 'nov'.
".*" followed by any no. of any characters.
"2007" followed by the string '2007'.
The -i option specifies to ignore case. Refer to the grep manpage (# man grep) for details.