Skip to content

Instantly share code, notes, and snippets.

View stephencroberts's full-sized avatar

Stephen Roberts stephencroberts

View GitHub Profile
@stephencroberts
stephencroberts / log.sh
Last active May 15, 2019 18:35
Shell script function for logging with log levels and custom formatting (POSIX compatible)
##############################################################################
# Logs messages with a configurable logging level and format, accepting input
# from either stdin (such as a pipe) or as arguments
#
# Author: Stephen Roberts <[email protected]>
#
# Globals:
# LOGLEVEL - arbitrary integer for desired log output level (default: 0)
#
# Arguments:
@stephencroberts
stephencroberts / twto.sh
Last active May 4, 2019 01:03
Shell script to time a command with a timeout (POSIX compliant)
#!/bin/sh
#
# Time a command with a timeout
#
# Author: Stephen Roberts <[email protected]>
# Version: 1
#
# Usage: twto [OPTIONS] TIMEOUT COMMAND
#