[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-newbie
Subject:    Re: Text Reformatting
From:       Stephen Samuel <samuel () bcgreen ! com>
Date:       2003-05-20 9:59:28
[Download RAW message or body]

Peter wrote:
> Thanks Stephen,
> 
> sed 's/^[ \t]+//' file does not work, it changes nothing.
> 
> 
> samuel@bcgreen.com said:
> 
>>Note that when you do the " tr [options] > somefile | fmt [options]
>>somefile" , you're losing any advantage of using a pipe. 
> 
> 
> Well taken tip!
> 
> Regards

Grr... I forgot the backslash before the '+'   That should be:

sed 's/^[ \t]\+//' file

(you could also do
	sed 's/^[ \t]*//' file


The '+' construct is (technically) a bit more efficient -- it won't
do a  null replacement for an unindented line.  It is, however, an
extended pattern and I sometimes worry about it's portability to
older (non-gnu) versions of sed. Ha! but never mind! Even that \t
turns out not to be portable to BSD. you need to have the literal
'tab' character.  It turns out that the most portable form is:

sed 's/^[ 	]*//' file
(with a space and a tabe between the sqquare brackets).  You might
need to do a ctrl-v o get bash to accept the tab caracter.

-- 
Stephen Samuel +1(604)876-0426                samuel@bcgreen.com
		   http://www.bcgreen.com/~samuel/
Powerful committed communication, reaching through fear, uncertainty and
doubt to touch the jewel within each person and bring it to life.

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic