<p>I would like to list pods created within 24 hours. I didn't find any kubectl commands or anything to get those. Could anyone please help me with the kubectl command to get only the pods created in last 24 hours.</p>

<p>Previous answers didn't work to me, the regex seems wrong and the field with the actual creationTimestamp is the sixth as per today, so :</p>
<pre><code>kubectl get pods -A --sort-by=.metadata.creationTimestamp | awk 'match($6,/^[0-9]+[sm]{1}|^[0-5][0-9]m|^[1-9]h|^1[0-9]*h|^2[0-4]h/) {print $0}'
</code></pre>
<p>It may be also useful to append <code>|grep -v Completed</code> to filter out Completed pods/jobs.</p>
<p><a href="https://regex101.com/r/l5gLKu/1" rel="nofollow noreferrer">https://regex101.com/r/l5gLKu/1</a></p>
<p>Client Version: v1.26.1<br />
Kustomize Version: v4.5.7<br />
Server Version: v1.25.5</p>
<p>Fatality:</p>
<pre><code>alias kpods1day=&quot;kubectl get pods -A --sort-by=.metadata.creationTimestamp | awk 'match(\$6,/^[0-9]+[sm]{1}|^[0-5][0-9]m|^[1-9]h|^1[0-9]*h|^2[0-4]h/) {print \$0}' |grep -v \&quot;Completed\|kube-system\&quot;&quot;  
alias kpods2days=&quot;kubectl get pods -A --sort-by=.metadata.creationTimestamp | awk 'match(\$6,/^[0-9]+[sm]{1}|^[0-5][0-9]m|^[1-9]h|^1[0-9]*h|^[2-3][0-9]h|^4[0-8]h/) {print \$0}' |grep -v \&quot;Completed\|kube-system\&quot;&quot;
</code></pre>
