bashoneliners.com

Welcome to bashoneliners.com, a curated collection of practical and well-explained Bash one-liners, snippets, tips and tricks. We aim to make each published one-liner to be of high quality: useful, easy to read, follows best practices, with clear, detailed, accurate explanation. These one-liners should help you automate tasks, troubleshoot problems, whether it be in system administration, file management, networking or programming.

Get AWS Instance-ID from all Kubernetes nodes

kubectl get node -ojson | jq -r '.items[].spec.providerID' | cut -d/ -f5 | tr -d '"'

June 29, 2023tanmay-bhat

Really lazy way to print the first instance of $foo that occurs after $bar

ifconfig | grep ^en1 -A5 | grep inet | head -n 1

May 12, 2012bashoneliners

Print the first instance of $foo that occurs after $bar

awk '/interface Ethernet3\/1/ {instanza=1} /!/ {instanza=0} instanza && /ip address/ {print}' file...

May 11, 2012Anon1UHy2ubE