#!/bin/bash LON="8° 02' 41.9\"W" LAT="39° 57' 00.0\"N" deg_to_dec() { deg=$(echo "$@"|awk -F\° '{ print $1 }') ARG=$(echo "$@"|awk -F\° '{ print $2 }') min=$(echo "$ARG"|awk -F\' '{ print $1 }') ARG=$(echo "$ARG"|awk -F\' '{ print $2 }') sec=$(echo "$ARG"|awk -F\" '{ print $1 }') operation="scale=10; ( $deg + $min / 60 + $sec / 3600 )" echo $ARG|grep -ioE "[ws]$" >/dev/null && operation="$operation * -1" bc <<< "$operation" } echo "` deg_to_dec $LAT `:` deg_to_dec $LON `"