Bash: Find All Folders Containing File With Name

fileName="my-file.yaml"
find . -type d \! -exec test -e '{}/'$fileName \; -print

This could easily be extended to do different tests on the folder by changing the -exec block to something else.

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]

Looping Dates macOS

date on MacOS does not support --date, so a workaround is needed. Converting Date to unix epoch, adding one day in epoch and converting back. The Scripty Way Taken from a blog post #!/bin/zsh start=$year-01-01 end=$year-12-31 currentDateTs=$(date -j -f "%Y-%m-%d" $start "+%s") endDateTs=$(date -j -f "%Y-%m-%d" $end "+%s") offset=86400 while [ "$currentDateTs" -le "$endDateTs" ] do date=$(date -j -f "%s" $currentDateTs "+%Y-%m-%d") echo $date currentDateTs=$(($currentDateTs+$offset)) done The Brew Way As I found out long after writing the above you can simply brew install coreutils and get a date command with the --date option. [Read More]
macos  bash