OK last commit didn't work. Replaced sed with perl.