Skip to content

Instantly share code, notes, and snippets.

View forestbaker's full-sized avatar

input - process - output forestbaker

View GitHub Profile
@forestbaker
forestbaker / cookbook.txt
Last active January 27, 2016 22:55
Brevis pimentorum que in domo esse debeant
# 88
echo '======================================================================================='
# 80
echo '==============================================================================='
# 75
echo '=========================================================================='
@forestbaker
forestbaker / cat_does_more.sh
Last active December 5, 2015 08:02
useful use of cat
#!/bin/bash
clear
#set -xv
HOME="$(pwd -P)"
#
printf '\n%s\n' 'cat is a core binary utility that is used to "concatenate" files'
#man cat
#
printf '\n\n%s\n\n' 'create things filled with no thing'
[ -f ./file1 -a -f ./file2 ] && rm -f ./file[1,2] || touch ./file1 ./file2
###############################
# FAHD SHARIFF'S BASH PROFILE #
###############################
HISTCONTROL=ignoredups
EDITOR=emacs
set -o notify
set -o braceexpand
set -o emacs
@forestbaker
forestbaker / DirCmp.sh
Last active November 20, 2015 17:43
Oldies but Goodies
#!/bin/sh
#
# Copyright 1995, by Hewlett-Packard Company
#
# The code in this file is from the book "Shell Programming
# Examples" by Bruce Blinn, published by Prentice Hall.
# This file may be copied free of charge for personal,
# non-commercial use provided that this notice appears in
# all copies of the file. There is no warranty, either
# expressed or implied, supplied with this code.
@forestbaker
forestbaker / knock_knock
Created October 12, 2015 01:45
port knocker - input target server DNS name followed by space separated ports
# port knocker - input target server DNS name followed by space separated ports
# usage - Knock_Knock bob.test.foo 55000 54000 53000
Knock_Knock() {
local SERVER="$1"
shift
for PORT
nmap -Pn --host_timeout 10 --max-retries 0 -p "$PORT" "$SERVER"
done
# ==[ printSlack ]=============================================================
# Function to send output from the commandline to Slack.
#
# @parameter string $LEVEL INFO/ERROR/WARNING message. Changes emoji
# @parameter string $MESSAGE Message to send to slack.
printSlack()
{
SLACK_HOSTNAME=${SLACK_HOSTNAME-'oops.slack.com'};
SLACK_TOKEN=${SLACK_TOKEN-'oops'};
SLACK_CHANNEL=${SLACK_CHANNEL-'#devops'};
@forestbaker
forestbaker / kvdiff
Created October 11, 2015 22:03 — forked from nemasu/kvdiff
Bash function that compares files containing key-value pairs.
#$1,2 = files containing x=y style key-values
#sort, awk, grep friendly
#Duplicate keys are not handled
function kvdiff() {
tmpfile=`mktemp`
OLD_IFS=$IFS;
IFS=$'\n'
declare -A left;
declare -A right;
@forestbaker
forestbaker / Notes
Created October 11, 2015 21:59 — forked from slank/Notes
Bash Power Tips Walkthrough
# Variables
FOO=here
FOO="here" # equivalent, always use quotes
BAR=$FOO
BAR="$FOO"
BAR="${FOO}"
BAR='$FOO' # single quotes, does not evaluate the variable
@forestbaker
forestbaker / send_text_with_data
Created October 11, 2015 21:45 — forked from vladkosinov/send_text_with_data
Send message in telegram from bash script
#!/bin/bash
if [ $# -lt 2 ]; then
echo "Usage: send.bash USER_NAME MESSAGE [DATA ... DATA]"
exit 1
fi
USER=$1
MESSAGE=$2
if [ $# -ge 3 ]; then
@forestbaker
forestbaker / mysql_db_sync
Created October 11, 2015 21:42 — forked from vasiliishvakin/mysql_db_sync
Simple bash script to sync remote mysql db to local
#!/bin/bash
LOCAL_DB=""
REMOTE_DB=""
LOCAL_USER="root"
LOCAL_PASS=""
REMOTE_USER="root"
REMOTE_PASS=''