I have to look for two strings in a given output. Lookup has to be AND and not OR. I just want to list lines that has strings "mlm" and "dgx" in the given output in every iteration.
say i am getting below output 10 times but out of those, only few has both the strings, then i only want to print those few that has both the strings present in the output of that iteration.
so, I read this but no luck.. how-to-run-grep-with-multiple-and-patterns
my tries:
kubectl get nodes -l nodeGroup=gpu -o wide --no-headers | sed -n -e 1,1p | xargs -l1 -- sh -c 'kubectl get pods --all-namespaces -o wide --field-selector=spec.nodeName=$1,status.phase=Running' -- | awk '{print $1,$2}'
Output 1
kube-system nginx-proxy-mlmpx100k8s0223p
kube-system nginx-proxy-zlmpx100k8s0223p
team1-92a20add-8857-4e94-a8b6-628db4a65e5e nominal-rigs-e2e-a1xpa-gpu-pool-62b857e3-153-5b58d86c6d-tt67w
team2-92a20add-8857-4e94-a8b6-628db4a65e5e nominal-rigs-e2e-a1xpa-gpu-pool-62b857e3-153-5b58d86c6d-tt67w
kubectl get nodes -l nodeGroup=gpu -o wide --no-headers | sed -n -e 1,1p | xargs -l1 -- sh -c 'kubectl get pods --all-namespaces -o wide --field-selector=spec.nodeName=$1,status.phase=Running' -- | awk '{print $1,$2}' | awk '/mlm/ && /team1/'
Output 2
nothing prints
expected output:
kube-system nginx-proxy-mlmpx100k8s0223p
team1-92a20add-8857-4e94-a8b6-628db4a65e5e nominal-rigs-e2e-a1xpa-gpu-pool-62b857e3-153-5b58d86c6d-tt67w