<p>I try to check <strong>how many</strong> nodes are <strong>ready</strong> (not including nodes tainted <strong>NoSchedule</strong>) and write <strong>the number</strong> to text file <strong>output.txt</strong>.</p>
<p>Could you give me any advice?</p>

O.Man
<p>I believe that <code>kubectl get nodes</code> doesn't show taints, so you can't just filter with <code>grep</code>. In that case you can set the output as json and use <a href="https://stedolan.github.io/jq/" rel="nofollow noreferrer">jq</a> (or yaml and use <a href="https://mikefarah.gitbook.io/yq/" rel="nofollow noreferrer">yq</a>) to process it:</p>
<pre><code>kubectl get nodes -o json | jq -c '.items[].spec.taints' | grep -v NoSchedule | wc -l &gt; output.txt
</code></pre>
<p><code>-c</code> option in <code>jq</code> is to output each element in a single line, instead of pretty printing it, in case you have multiple taints. The rest has already been explained in <a href="https://stackoverflow.com/questions/62921626/how-to-exclude-taint-nodes-from-outputs-in-kubectl-get-nodes/62921857#62921857">Abdennour TOUMI's answer</a></p>
