ormaaj 1390104035 learn trim whitespace, like SQL TRIM(): foo="${foo##+( )}" foo=${foo%%+( )} ormaaj 1390104051 forget ormaaj 1390104862 learn trim whitespace, like SQL TRIM() -- For shell variables: «shopt -s extglob; x=${x##+([[:space:]])} x=${x%%+([[:space:]])}». For streams: «cmd | sed 's/^[[:space:]]*\(.*[^[:space:]]\)[[:space:]]*$/\1/'» other methods: http://stackoverflow.com/a/15219697/495451 ormaaj 1411587499 forget ormaaj 1411587509 learn learn trim whitespace, like SQL TRIM() -- For shell variables: «shopt -s extglob; x=${x##+([[:space:]])} x=${x%%+([[:space:]])}». For streams: «cmd | sed 's/^[[:space:]]*\(.*[^[:space:]]\)[[:space:]]*$/\1/'». See: http://mywiki.wooledge.org/BashFAQ/067 Riviera 1412690097 forget Riviera 1412690120 learn trim whitespace, like SQL TRIM() -- For shell variables: «shopt -s extglob; x=${x##+([[:space:]])} x=${x%%+([[:space:]])}». For streams: «cmd | sed 's/^[[:space:]]*\(.*[^[:space:]]\)[[:space:]]*$/\1/'». See: http://mywiki.wooledge.org/BashFAQ/067 geirha 1413834408 forget geirha 1413834410 learn trim whitespace, like SQL TRIM() -- For shell variables: «shopt -s extglob; x=${x##+([[:space:]])} =${x%%+([[:space:]])}». For streams: «cmd | sed 's/^[[:space:]]*//; s/[[:space:]]*$//'». See: http://mywiki.wooledge.org/BashFAQ/067 geirha 1413834483 forget geirha 1413834488 learn trim whitespace, like SQL TRIM() -- For shell variables: «shopt -s extglob; x=${x##+([[:space:]])} x=${x%%+([[:space:]])}». For streams: «cmd | sed 's/^[[:space:]]*//; s/[[:space:]]*$//'». See: http://mywiki.wooledge.org/BashFAQ/067