fixed bash problem with substring extracion