DNS is something so fundamental to most of our systems functioning that it’s often overlooked in initial troubleshooting, it’s also incredibly hard to troubleshoot if it’s only intermittently failing.
[Read More]Running Multiple Server Processes From One Script
Doing local development on a bunch of interconnected services I often want to start multiple long running server processes.
This is the basic script I use for that.
[Read More]Cleanup After Script Exit
Many of my scripts work with temporary files, usually relative to the scripts directory1,
while at the same time using set -e
to exit as soon as something fails.
In this scenario the script leaves behind these temporary files by default, which is not desireable.
We can however do a proper cleanup using the trap
concept.
Find files and folders with spaces
On Linux/Unix/MacOS:
find . | grep " "
On Windows:
Get-ChildItem -Path "." -Recurse -Filter "* *" | Format-Table FullName
Bash: Find All Folders Containing File With Name
fileName="my-file.yaml"
find . -type f -name "$fileName" -printf "%h\n"
Working With Dates in Bash and Other Shells
Often times we need the current date (and time) when scripting inside bash or other shells. For example when creating a backup file or writing to a log.
[Read More]Navigate to Script Directory
Often times when writing scripts I want to reference files in the same directory, but keep the script portable in case it is part of a git repository being checked out somewhere else or just the folder getting moved.
[Read More]Copy & Paste Is Dangerous
Copy & paste from untrusted sources on the internet into the terminal is a really bad idea! Early in my career I did it too and still often see others doing it.
[Read More]