[Updated] usage of basename to bash string manipulation