#!/bin/bash trim() { local input="${1}" while [[ "${input}" == " "* ]]; do input="${input## }" done while [[ "${input}" == *" " ]]; do input="${input%% }" done echo "${input}" }