simplified string processing

avoiding sed if bash utulities are available