Skip to navigation

Archive for the 'Regular expressions' Category

Sed example 2

Monday, June 25th, 2007

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]*$//’

Sed example 1

Tuesday, May 1st, 2007

Many things are easiest to learn by looking at examples. I find this to be especially true for sed. Sed stands for “stream editor”, and it is very handy to perform bulk editing of text files. To get started, I refer you to this very nice tutorial. I’m planning to archive some of the small […]