Skip to content

Instantly share code, notes, and snippets.

@kylebarron
Created July 24, 2018 23:42
Show Gist options
  • Save kylebarron/d5253d3a1f69d67e983b546ba88f1f4b to your computer and use it in GitHub Desktop.
Save kylebarron/d5253d3a1f69d67e983b546ba88f1f4b to your computer and use it in GitHub Desktop.
Check Stata log for errors and issue a non-zero return code if an error occurred.
#! /usr/bin/env bash
# Check Stata log for errors and issue a non-zero return code if an error
# occurred.
#
# The idea for this came from
# https://gist.github.com/pschumm/b967dfc7f723507ac4be
# Accepts either:
# a single argument, the log file
# the log file piped to stdin
if egrep --before-context=1 --max-count=1 "^r\([0-9]+\);$" "${1:-/dev/stdin}"
then
exit 1
else
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment