<p>I have generated a bunch of namespaces like below and now i want to delete only these name spaces without deleting kube-system namespaces,i tried with grep but no success</p>

<blockquote>
  <p>kubectl delete namespaces | grep "gatling*"
  error: resource(s) were provided, but no name, label selector, or --all flag specified</p>
</blockquote>

<p><a href="https://i.stack.imgur.com/UNL86.png" rel="nofollow noreferrer">Multiple namespaces</a></p>

<p>First get the names of the namespaces you want to delete:</p>

<pre><code>kubectl get namespaces --no-headers=true -o custom-columns=:metadata.name | grep gatling
</code></pre>

<p>With <code>-o custom-columns=:metadata.name</code> we output only the names of the services. The output is piped to <code>grep</code>, which filters them by looking for <code>gatling</code>.</p>

<p>Then run the delete command for each line with <code>xargs</code>:</p>

<pre><code>kubectl get namespaces --no-headers=true -o custom-columns=:metadata.name | grep gatling | xargs kubectl delete namespace
</code></pre>
