Skip to main content

Bash function to remove unwanted characters from a name.

#!/usr/bin/env bash

#
# Remove unwanted characters from a name.
#
# @param  name
# @return input, but stripped to a) alpha-numberical letters
# 	or b) _.- punctuation marks
#
# https://github.com/eBay/ebashlib/blob/develop/bashlib/fileSanity/fileSanity.sh#L18
sanitize_name() {
    tr -c -d '[:alnum:]_.-' <<< "$1"
}