Bash: replace all occurrences of char
20 December 2025 (Updated 20 December 2025)
#!/bin/bash
set -euo pipefail
# Remove all "a" chars with an asterisk "*"
function remove_spaces() {
local str=$1
echo "${str//a/*}"
}
remove_spaces "sajad torkamani"
Tagged:
Bash recipes