Skip to content

Instantly share code, notes, and snippets.

@goldie-lin
goldie-lin / trim.sh
Last active September 29, 2022 00:39
bash: trim leading & trailing whitespace chars in a variable
#!/usr/bin/env bash
# Function definitions
# --------------------
# trim leading & trailing whitespace chars
trim() {
local var="$1"
var="${var#"${var%%[![:space:]]*}"}" # trim leading whitespace chars
var="${var%"${var##*[![:space:]]}"}" # trim trailing whitespace chars
@stevehorn
stevehorn / gist:851722
Created March 2, 2011 20:53
VB.Net Dictionary Initializer
'This language is tortured, I tell you
Dim variable As New Dictionary(Of String, Boolean) From {{"Dumb", True}, {"Idiotic", True}}