If the file has-apple,orange,bananaorangeora,orange,appleapple,oraorange,apple,ora,bananaI want to print only lines containing ora and orange-ora,orange,appleorange,apple,ora,banana
How can I print the lines in a file that contain two regex where one is the substring of another
text processing
With single egrep:egrep 'ora\b.*orange|orange.*ora\b' fileThe output:ora,orange,appleorange,apple,ora,bananaOr with single sed expression:sed -n '/orange/{/ora\b/p}' fileora,orange,appleorange,apple,ora,bananaIn both approaches \b (word boundary) is used.