20 06 2016
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:
echo " a b c d " | awk '{$1=$1};1'
prints:
"a b c d"
For convenience, i created /usr/bin/trim with this content:
#!/bin/bash awk '{$1=$1};1'
which then allows
echo " a b c d " | trim
Enable mouse scrolling inside screen sessions Effectively storing multiple text files
Comments are currently closed.