Replace spaces with underscores via BASH July 21, 2023 by Tarik You could try the following: str="${str// /_}"