aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%/.bash_utils
diff options
context:
space:
mode:
Diffstat (limited to '%HOME%/.bash_utils')
-rw-r--r--%HOME%/.bash_utils/text.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/%HOME%/.bash_utils/text.sh b/%HOME%/.bash_utils/text.sh
index 1ce36a6..4ecffd6 100644
--- a/%HOME%/.bash_utils/text.sh
+++ b/%HOME%/.bash_utils/text.sh
@@ -41,3 +41,36 @@ replace_word() (
sed --binary --in-place "s/\\b$old\\b/$new/g" "$@"
)
+
+str_tolower() (
+ set -o errexit -o nounset -o pipefail
+
+ local s
+ for s; do
+ echo "${s,,}" # | tr '[:upper:]' '[:lower:]'
+ done
+)
+
+str_toupper() (
+ set -o errexit -o nounset -o pipefail
+
+ local s
+ for s; do
+ echo "${s^^}" # | tr '[:lower:]' '[:upper:]'
+ done
+)
+
+str_contains() (
+ set -o errexit -o nounset -o pipefail
+
+ if [ "$#" -ne 2 ]; then
+ echo "usage: ${FUNCNAME[0]} STR SUB"
+ return 1
+ fi
+
+ local str="$1"
+ local sub
+ sub="$( printf '%q' "$2" )"
+
+ test "$str" != "${str#*$sub}"
+)