refine the bash shell var remove pattern instead of using basename