If packagehello does not match, the output is still displayed.
Aim: to see no output in situation 2
Situation 1:
user@hostname ~]$ sudo yum list 'package*'
packagehello
packagehello
package2world
packagehello
package2world
Situation 2:
user@hostname ~]$ sudo yum list 'package*' | grep -E 'package1.*|package2.*'
package2world
package2world
How to show the output only if both words match using grep?
packagehellomatches neitherpackage1.*notpackage2.*. Are you sure of your output?