mix of ‘and’, ‘or’ operators in shell script

Dipesh Majumdar
Apr 21, 2023

you can have a mix of and and or in shell script. suppose you want to search for (pattern1 and pattern2) or (pattern3 and pattern4), then this is how you can do —

As an example, i want to query all the develop env deployment whose names have develop-author… or develop-publish… , then this is how i can filter :

MacBook-Pro-van-Dipesh:develop dipeshmajumdar$ k -n aem get deploy |grep 'develop.*publish\|develop.*author'
develop-author 0/0 0 0 81d
develop-author-dispatcher 0/0 0 0 6h40m
develop-publish 0/0 0 0 81d
develop-publish-dispatcher 0/0 0 0 6h42m

This will search patterns with develop followed by publish and develop followed by author as shown in the above output

--

--