Skip to navigation

Sed example 2

Replacing whitespace, lifted directly from the handy collection of sed one-liners at Sourceforge:

Delete all leading whitespace from line (tabs and spaces):

sed 's/^[ \t]*//'

Delete whitespace at end of line:

sed 's/[ \t]*$//'

Delete leading and trailing whitespace:

sed 's/^[ \t]*//;s/[ \t]*$//'

Comments are closed.