Skip to content

Instantly share code, notes, and snippets.

View digitaljhelms's full-sized avatar

Jeremy Helms digitaljhelms

  • USA
View GitHub Profile
@digitaljhelms
digitaljhelms / httpcode
Last active August 27, 2019 04:34
CLI to evaluate the HTTP Code for a list of URLs
#!/bin/bash
while IFS= read -r LINE || [ "$LINE" ]; do
# https://curl.haxx.se/docs/manpage.html
IN=$(curl -o /dev/null --silent --head --write-out "%{http_code};%{redirect_url}" "$LINE")
# https://stackoverflow.com/a/5257398
arrIN=(${IN//;/ })
if [ "${arrIN[0]}" = "301" ] || [ "${arrIN[0]}" = "302" ]; then
@digitaljhelms
digitaljhelms / color
Created June 17, 2021 02:26
Include files for bash scripts
#!/bin/bash
# check if stdout is a terminal
if [ -t 1 ]; then
# see if it supports colors
ncolors=$(tput colors)
if [[ -n "$ncolors" && $ncolors -ge 8 ]]; then
bold="$(tput bold)"
underline="$(tput smul)"