<p>It's best to explain with an example what I want to achieve.</p>

<p>I have this kubectl output:</p>

<pre><code>app-bf7c5cdfb-x8thq   3/3     Running   0          2h
app-bf7c5cdfb-xc9nf   3/3     Running   0          2h
app-bf7c5cdfb-xwlzh   2/3     Running   0          1h
app-bf7c5cdfb-xxt46   3/3     Running   0          2h
app-bf7c5cdfb-z9s2t   2/3     Running   0          7m
app-bf7c5cdfb-zmpzs   3/3     Running   0          2h
app-bf7c5cdfb-ztfx5   3/3     Running   0          2h
</code></pre>

<p>I want to grep for each line, where the ready pods are not equal to the total pods resulting in:</p>

<pre><code>app-bf7c5cdfb-xwlzh   2/3     Running   0          1h
app-bf7c5cdfb-z9s2t   2/3     Running   0          7m
</code></pre>

<p>Is there a simple way to do that? My approach is writing a function like this:</p>

<pre><code>function kubeNotReady {
    unset tmp
    while :
    do 
        read line
        [[ $line == "" ]] &amp;&amp; tmp="${tmp:0:$((${#tmp}-1))}" &amp;&amp; break

        total=`echo "$line" | sed -E "s|.*[[:digit:]]*/([[:digit:]]*).*|\1|"`
        match=`echo "$line" | grep -v "$total/$total"`
        if [ "${#match}" -gt "0" ]; then
            tmp="$tmp$match"$'\n'
        fi
    done
    echo "$tmp"
}
</code></pre>

<pre><code>kubectl get po | kubeNotReady
</code></pre>

Antman
<p>If <code>AWK</code> is your option, please try the following:</p>

<pre><code>awk '{split($2, a, "/"); if (a[1] != a[2]) print}' out.txt
</code></pre>

<p>As an alternative, you can say with <code>bash</code> as:</p>

<pre><code>while IFS= read -r line; do
    [[ $line =~ [[:blank:]]([[:digit:]]+)/([[:digit:]]+)[[:blank:]] ]] &amp;&amp; (( ${BASH_REMATCH[1]} != ${BASH_REMATCH[2]} )) &amp;&amp; echo "$line"
done &lt; out.txt
</code></pre>

<p>Hope this helps.</p>
