Trimming Whitespace From Beginning and end of Text Lines

No at SPAM at mgEDV.net nospam at mgedv.net
Fri May 12 08:56:22 PDT 2006


 
> > 	sed -i -e 's/^[[:space:]]*' -e 's/[[:space:]]*$//' file ...

why not use just (you can change the "-" separator to "/" as above):
sed -e 's-^ *--g' -e 's- *$--g'

usage examples:
-> cat file| sed ... >file1
-> echo $variable| sed ... |grep xy
-> if [ "`echo $xy|sed ...`" = "blabla bla" ]; then ...

cu...



More information about the freebsd-questions mailing list