#!/bin/bash
#                       /usr/local/bin/license
#  http://crystalfaeries.net/posix/bin/license
# celeste:crystalfaery 2016-02-19 08:55:05+00:00
# http://oioannou.com/2016/blog/one-liner/

function license-of {
    readlink -f $1 | xargs dpkg-query --search | awk -F ": " '{print $1}' | xargs apt-cache showsrc | grep-dctrl -s 'Package' -n '' | awk -v sha="$(sha256sum $1 | awk '{ print $1 }')" -F " " '{print "https://sources.debian.net/copyright/api/sha256/?checksum="sha"&packagename="$1""}' | xargs curl -sS
}

CMD="$1"
license-of ${CMD}


syntax highlighted by Code2HTML, v. 0.9.1