#!/usr/bin/env bash

trim() {
    local var="$*"
    var="${var#"${var%%[![:space:]]*}"}"   # remove leading whitespace characters
    var="${var%"${var##*[![:space:]]}"}"   # remove trailing whitespace characters
    echo -n "$var"
}

var=" - Hallo Welt - "

echo ""
echo "   |${var}|"

var="$(trim $var)"
echo "   |${var}|"

echo ""
exit 0
