Subjectively

dd if=/dev/random | kirk > blog

Subjectively header image 2

sed script to trim leading and trailing spaces

February 25th, 2009 · No Comments · Linux, OS X

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!

Tags:

No Comments so far ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment

You must log in to post a comment.