Skip to content

Instantly share code, notes, and snippets.

View mtarbit's full-sized avatar

Matt Tarbit mtarbit

View GitHub Profile
@mtarbit
mtarbit / listening.sh
Last active October 10, 2016 13:14
A bash function wrapper for lsof to find any listening processes.
listening() {
if [ -z "$1" ]; then
lines=$(lsof -P -s TCP:LISTEN -i TCP | tail -n +2)
pairs=$(echo -n "$lines" | awk '{split($9,a,":"); print $2":"a[2]}' | uniq)
format_string="%5s %5s %s\n"
if [ -n "$pairs" ]; then
printf "$format_string" "PORT" "PID" "COMMAND"
for pair in $pairs; do
@mtarbit
mtarbit / backup.sh
Last active December 10, 2015 21:48
Ubuntu backup script
#!/bin/bash
curr_date="$(date +%Y%m%d)"
base_path="/mnt/Elements/backup.$curr_date"
tgz_path="$base_path.tgz"
out_path="$base_path.out.log"
err_path="$base_path.err.log"
if [[ $EUID -ne 0 ]]; then