<p>script will need to check if aaa-new-ui-dev and bbb-java-new-ui-dev namespace exist - and if it exists - it needs to delete them and wait until delete operation is complete</p>
<p>I am trying to create a shell script which check if namespace is exist and if it exists then it should delete the kubectl namespace.</p>

vikash sharma
<pre class="lang-bash prettyprint-override"><code># For each namespace to delete.
for ns in aaa-new-ui-dev bbb-java-new-ui-dev ; do 
  # If 'get' returns 0, then the namespace exists. 
  if kubectl get namespace/$ns ; then
    # Issue delete. 
    kubectl delete namespace/$ns
    # Wait up to 30 seconds for deletion.
    kubectl wait --for=delete namespace/$ns --timeout=30s
  else
    # Get returned an error. Assume namespace does not exist.
    echo &quot;$project does not exist; skipping delete&quot;
  fi
done
</code></pre>
