>Sluggers
>
>This is driving me nuts, I've doen this before and do you think I can
>drag the command out of my memory! What's the syntax in sed that puts
>the wild card expresion matched in the first side of the substitute back
>in on the replace side?
>
>EG
>
> echo " Hello To The World,\nGday to Oz,\nHi Sluggers," |
> sed 's/ .*,/#[]#/'
> ^^
> what goes in here to put what was matched by ".*" back into the replace
> string so the result of the above is
echo " Hello To The World,\nGday to Oz,\nHi Sluggers," |
sed 's/ \(.*\),/#\1#/'
I assume those are real newlines, not \n or there will be only one
match. Also you should realise that the match is greedy so it will grab
not just the word before the , but as far back to the beginning of the
line as it can. Exercise left to you.
--
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug