Home > Back-end >  How count number of lines in linux excluding headers?
How count number of lines in linux excluding headers?

Time:10-13

I have to count the number of replicasets running in a system.

kubectl get replicasets | wc -l

It give output 2 as it counts the header as well.

NAME              DESIRED   CURRENT   READY   AGE
new-replica-set   4         4         0       20s

How to print the count excluding the headers?

CodePudding user response:

add no-headers

kubectl get replicasets --no-headers | wc -l

if you want to count rs from all namespaces just add -A before --no-headers

kubectl get replicasets -A --no-headers | wc -l

  • Related