i couldn’t find this anywhere, so just to make it generally public, this is my trim function:
sed ‘s/^[[:space:]]*\(.*\)[[:space:]]*$/\1/’
For who’s looking, this command says:
from beginning of line ^
take any amount of whitespace [[:space:]]
then create a group containing anything \(.*\)
up to whitespace at the end of the line [[:space:]]*$
replace this with the group \1 only (effectively removing the whitespace)
enjoy!
No Comments so far ↓
There are no comments yet...Kick things off by filling out the form below.