Re: File - sed1line.txt

"'Ruud H.G. van Tol' [email protected] [sed-users]" <[email protected]> Fri, 1 Jul 2016 16:38:36 +0200
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
On 2016-07-01 15:57, [email protected] wrote:

>  # delete leading whitespace (spaces, tabs) from front of each line
>  # aligns all text flush left
>  sed 's/^[ \t]*//'                    # see note on '\t' at end of file
>
>  # delete trailing whitespace (spaces, tabs) from end of each line
>  sed 's/[ \t]*$//'                    # see note on '\t' at end of file
>
>  # delete BOTH leading and trailing whitespace from each line
>  sed 's/^[ \t]*//;s/[ \t]*$//'

The '*' should be "1 or more" instead.

Now it matches every line,
including the ones without whitespace at either end.

Also, removing whitespace from the end first,
generally leaves less characters to move.

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

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

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


(yeah, benchmark-food)

-- Greetings, Ruud