123456789101112131415161718192021222324 |
- #!/bin/sh --
- set -ue
- : "${1:?}" "${2:?}" "${3:?}"
- gcd() {
- while [ "${2:?}" -ne 0 ]; do
- set -- "${2:?}" "$(( ${1:?} % ${2:?} ))"
- done
- echo "${1:?}"
- }
- gcd="$(gcd "${2}" "${3}")"
- aspect="$(( ${2} / gcd )):$(( ${3} / gcd ))"
- s=" " # field separator
- filename="${1##*/}"
- geometry="${2}x${3}"
- filesize="$(du -h -- "${1}")"
- filesize="${filesize%$(printf %b '\t')*}"
- printf %s "${filesize% *}${s}${geometry}${s}${aspect}${s}${filename}"
|