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 [...]
Entries from February 25th, 2009
sed script to trim leading and trailing spaces
February 25th, 2009 · No Comments · Linux, OS X
Tags: