baumi's blog

baumi's personal blog … Linux, OS X, Windows, Random things, …

Bash: trim left and right (leading and trailing whitespaces)

Wanted: remove leading and trailing whitespaces from variables or cat’d lines from a textfile. – Simple solution:

prints:

For convenience, i created /usr/bin/trim with this content:

which then allows

Comments are currently closed.