Here I have some grep command which is not working correctly:
cat file1.txt:
apples
Date: Sun, 24 Feb 2013 8:14:06 -0800
peaches melons
cherry sky cloud
green purple
yellow
cat file2.txt:
apples
Date
peaches melons 0800
cherry sky cloud
green purple
black
Now broken command is:
egrep -lir "apples|melons|cherry" /home/test/* | xargs grep -l "Date" | xargs grep -l "0800"
See first argument: file must contain apples OR melons OR cherry Then, second argument: same file must contain "Date" and "0800" ON SAME LINE
So file1.txt should match but not file2.txt - right now both match
Thanks for the help - I think I need grep with regexp to match "Date:[any][any][any]0800" type command to catch "Date" and "0800" on same line....