replace perl with grep/sed