Skip to content

Instantly share code, notes, and snippets.

View crazy-max's full-sized avatar

CrazyMax crazy-max

View GitHub Profile
@crazy-max
crazy-max / wget-file-list-recursively.sh
Created June 3, 2013 00:54
wget file list recursively see url decode gist to decode files found : https://gist.github.com/crazy-max/5695521
#! /bin/sh
function wgetFind() {
local host="$1"
local path="$2"
local files=$(wget -q -O - "$host$path" | grep -o 'ftp:[^"]*')
while read -r line
do
local file=$(echo "$line" | sed "s#&\#32;#%20#g" | sed "s#$host# #g" | cut -c2-)
if [ "${file#${file%?}}" == "/" ]
@crazy-max
crazy-max / wget-file-size.sh
Created June 3, 2013 00:43
file size with wget
#! /bin/sh
echo wget -S --spider -O - "http://www.foo.com/file" >&1 2>&1 | grep '^213' | awk '{print $2}'
@crazy-max
crazy-max / filter-wget-progress
Created June 3, 2013 00:42
filter wget progress - to display the progress bar only
#! /bin/sh
function wgetFilter() {
local flag=2 c count cr=$'\r' nl=$'\n'
while IFS='' read -d '' -rn 1 c
do
if [ $flag == 1 ]
then
printf '%c' "$c"
if [[ "$c" =~ (s$) ]]
#! /bin/sh
echo "http%3A%2F%2Fwww.foo.com%2Findex.php%3Fid%3Dqwerty" | sed -e "s/%\([0-9A-F][0-9A-F]\)/\\\\\x\1/g" | xargs -0 echo -e
# http://www.foo.com/index.php?id=qwerty
@crazy-max
crazy-max / timing.sh
Created June 3, 2013 00:32
Timing a script
#! /bin/sh
function formatSeconds() {
local s=${1}
((h=s/3600))
((m=s%3600/60))
((s=s%60))
if [ "${#h}" == 1 ]; then h="0"$h; fi
if [ "${#m}" == 1 ]; then m="0"$m; fi
if [ "${#s}" == 1 ]; then s="0"$s; fi
@crazy-max
crazy-max / log-all-output.sh
Last active December 18, 2015 00:19
Log all output
#! /bin/sh
LOG_FILE="/tmp/script-output.log"
function watchTail() {
local cur_pid=$$
local tail_args=`echo "tail -f $LOG_FILE" | cut -c1-79`
local pid=`ps -e -o pid,ppid,args | grep ${cur_pid} | grep "${tail_args}"| grep -v grep | nawk '{print $1}'`
if [ "$pid" = "" ]