> what is going to be in $1, $2... Is ghi the contents of $2 or not? this is easy to test:
; echo abcdefghi | sed 's/(abc(def)*)(ghi)/\1/' abcdef ; echo abcdefghi | sed 's/(abc(def)*)(ghi)/\2/' def ; echo abcdefghi | sed 's/(abc(def)*)(ghi)/\3/' ghi - erik