notes/technology/bash

Colorize pattern on CLI

Notes | 2025-05-07 (updated 2025-10-25) | 1 min read
#bash #grep #productivity

Colorize a pattern in the given input using a neat regex and colorization hack in grep ($ matching all lines but not being able to be highlighted).

color () {
  # Color highlight the pattern in the incoming stream, writing to stdout
  # This effectively matches our PATTERN andy any "$" (line end)
  # But only our PATTERN can be highlighted, line end characters aren't actually there to be highlighted
  local PATTERN=$1

  if [ -z "$1" ]; then
    echo "Usage: color <pattern>"
    echo "Description: Greps input with --color=always -E 'PATTERN|\$' "
    echo "Example: echo \"hello world\" | color \"world\""
    return 1

  fi
  grep --color=always "$PATTERN\|\$"
}

Running Multiple Server Processes From One Script

Notes | 2025-02-23 (updated 2025-10-25) | 1 min read
#bash #microservices #scripting

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…

Bash: Find All Folders Containing File With Name

Notes | 2024-03-01 (updated 2025-10-25) | 1 min read
#bash #scripting

fileName="my-file.yaml"
find . -type f -name "$fileName" -printf "%h\n"