15 Feb
2005
15 Feb
'05
2:01 p.m.
Richard Lewis wrote:
I need to match all the characters from either the beginning of the line or the last match (in global mode) up to the last space before the Xth character.
I can do the first space after the Xth character: $ echo "A string with quite a lot of words and spaces in it." | sed "s/\(.\{,X\}\) /\1\n/g"
Doesn't that do the last space before the (X+1)th character? I tested it a bit and it seems to. All you need to do is change the space to \( \|$\) so you don't always split the last word off, I think. -- MJR/slef http://mjr.towers.org.uk/