mort9.github.io

mort9 content

View My GitHub Profile

Bash Scripting

Current Directory for a Script

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

Handle SIGINT (Ctrl-c) signal for a script

function handle_sigint() # Kill all subprocesses and childs
{
    for proc in `jobs -p`
    do
        kill $proc
    done
}

cmd1 &
cmd2 &
...

trap handle_sigint SIGINT  # calls handle_sigint on SIGINT (ctrl-c)
wait

jq

jq '..|.updateDate?' # Skip non-json data